ci: enhance pr site preview comment and add concurrency#7
Conversation
|
Site preview available 🔗 https://ff4j.github.io/docs/pr-7/ |
There was a problem hiding this comment.
Pull request overview
This PR improves the GitHub Pages PR-preview workflow by preventing overlapping runs, preserving existing content on gh-pages when publishing PR previews, and making the preview link comment idempotent (update instead of spam).
Changes:
- Add workflow-level
concurrencyto cancel in-progress runs per ref. - Adjust PR preview deploy to target
gh-pagesexplicitly and keep existing files. - Update the PR preview comment step to find-and-update an existing comment via a marker.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner, | ||
| repo, | ||
| issue_number: pr, | ||
| body: `📘 **Site preview available**:\n\n${url}` | ||
| }); | ||
|
|
||
| const existing = comments.find(comment => | ||
| comment.body?.includes(marker) | ||
| ); |
There was a problem hiding this comment.
issues.listComments is paginated (default 30). If a PR has more than one page of comments, the marker comment may not be found and this can create duplicate preview comments. Consider requesting a larger per_page and/or paging through results (or using the paginate helper) before deciding whether to create vs update.
| if: github.event_name == 'pull_request' && | ||
| github.event.action == 'closed' && | ||
| github.event.pull_request.merged == false | ||
| github.event.action == 'closed' |
There was a problem hiding this comment.
The cleanup job now runs on every PR close, including merged PRs (previously it skipped merged==true). This changes behavior by deleting merged PR previews as soon as the PR is merged/closed; please confirm that’s intended (and update the PR description if so).
Checklist: