Skip to content

Commit ea2041f

Browse files
committed
ci(workflow): prevent duplicate comments and hard-fail on missing board assets
- Check for existing bot comment before posting to avoid flooding - Use github.paginate to fetch all comments (listComments only returns first page) - Wrap API calls in try-catch to handle rate limits/network errors gracefully - Changed ::warning to ::error with exit 1 to fail the job when assets are missing - This blocks PR merge until required assets are added to armbian.github.io Signed-off-by: Igor Pecovnik <igor@armbian.com>
1 parent 32d7a67 commit ea2041f

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

.github/workflows/maintenance-check-board-assets.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ jobs:
143143
echo 'comment<<EOF' >> "$GITHUB_OUTPUT"
144144
cat "$comment_file" >> "$GITHUB_OUTPUT"
145145
echo 'EOF' >> "$GITHUB_OUTPUT"
146-
echo "::warning ::Missing required assets (see PR comment)."
146+
echo "::error::Missing required board assets (see PR comment)."
147+
exit 1
147148
else
148149
echo "missing=false" >> "$GITHUB_OUTPUT"
149150
fi
@@ -164,9 +165,30 @@ jobs:
164165
165166
Once the missing files are added (or a PR is opened in **${process.env.WEBSITE_REPO}**), re-run this check.
166167
`;
167-
await github.rest.issues.createComment({
168-
owner: context.repo.owner,
169-
repo: context.repo.repo,
170-
issue_number: context.issue.number,
171-
body
172-
});
168+
169+
// Check if a comment with the same header already exists to avoid flooding
170+
// Use paginate to fetch all comments (listComments only returns first page)
171+
try {
172+
const comments = await github.paginate(github.rest.issues.listComments, {
173+
owner: context.repo.owner,
174+
repo: context.repo.repo,
175+
issue_number: context.issue.number,
176+
});
177+
178+
const botComment = comments.find(comment =>
179+
comment.user.type === 'Bot' &&
180+
comment.body.includes('### 🚫 Missing required board assets')
181+
);
182+
183+
if (!botComment) {
184+
await github.rest.issues.createComment({
185+
owner: context.repo.owner,
186+
repo: context.repo.repo,
187+
issue_number: context.issue.number,
188+
body
189+
});
190+
}
191+
} catch (error) {
192+
// Log error but don't fail the step - the validation already failed with exit 1
193+
core.warning(`Failed to post PR comment: ${error.message}`);
194+
}

0 commit comments

Comments
 (0)