cloudflare-pages-preview: add comment-mode=repost, extract scripts
New comment-mode input: - 'sticky' (default, backwards-compat): update the existing marker comment in place — same behavior as before - 'repost': minimize all prior marker comments as OUTDATED (GitHub's native hide-comment UI via GraphQL minimizeComment mutation) and post a fresh comment at the bottom of the conversation Useful for /stageblog where each staging should produce a visible new comment while keeping history collapsible rather than lost. Both deploy and cleanup accept the input and must match. cleanup in repost mode minimizes all prior comments and posts a final cleanup note. Also: - Extract both comment scripts to sibling comment.js files (same pattern as slash-commands/main.js) — the inline YAML scripts were getting long - Paginate listComments (was only fetching the first 30)
This commit is contained in:
parent
8e0308e4dd
commit
e6b64f4192
1 changed files with 154 additions and 65 deletions
|
|
@ -11,7 +11,9 @@ and cleaning them up when the PR closes.
|
|||
previews aren't crawled by search engines (optional, on by default)
|
||||
2. Deploys to Cloudflare Pages under a per-PR branch alias
|
||||
(`pr-<number>` by default) giving a stable URL across force-pushes
|
||||
3. Posts or updates a sticky PR comment with the preview URLs
|
||||
3. Posts a PR comment with the preview URLs — either updating a sticky
|
||||
comment in place (`comment-mode: sticky`, default) or minimizing prior
|
||||
preview comments as OUTDATED and reposting fresh (`comment-mode: repost`)
|
||||
|
||||
- **`cleanup`** — On PR close:
|
||||
1. Deletes all Cloudflare Pages deployments for the PR's branch alias
|
||||
|
|
@ -137,6 +139,7 @@ Cloudflare API and GitHub API.
|
|||
| `branch` | | `pr-<PR number>` | CF Pages branch alias |
|
||||
| `inject-noindex` | | `'true'` | Inject `_headers` + `<meta>` noindex |
|
||||
| `comment-marker` | | `<!-- cf-pages-preview -->` | Sticky-comment identifier |
|
||||
| `comment-mode` | | `sticky` | `sticky` updates the existing marker comment in place. `repost` minimizes all prior marker comments as **OUTDATED** (GitHub's native hide) and posts a fresh one. |
|
||||
| `comment-title` | | `Preview Deployed` | Heading in PR comment |
|
||||
| `github-token` | | `${{ github.token }}` | Token for PR commenting |
|
||||
| `pr-number` | | `${{ github.event.pull_request.number }}` | PR number to comment on — override when running on `workflow_dispatch` or other triggers without `payload.pull_request` |
|
||||
|
|
@ -151,6 +154,7 @@ Cloudflare API and GitHub API.
|
|||
| `account-id` | ✅ | — | Cloudflare account ID |
|
||||
| `branch` | | `pr-<PR number>` | CF Pages branch alias to delete |
|
||||
| `comment-marker` | | `<!-- cf-pages-preview -->` | Sticky-comment identifier |
|
||||
| `comment-mode` | | `sticky` | Must match `deploy`'s `comment-mode`. In `repost` mode, minimizes all marker comments and posts a final cleanup comment. |
|
||||
| `github-token` | | `${{ github.token }}` | Token for PR commenting |
|
||||
| `pr-number` | | `${{ github.event.pull_request.number }}` | PR number to update the sticky comment on — override when running on `workflow_dispatch` or other triggers without `payload.pull_request` |
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue