Add pr-number input to cloudflare-pages-preview actions
Both deploy and cleanup previously read context.payload.pull_request.number directly, which throws on workflow_dispatch and other non-PR triggers. New optional inputs: - deploy: pr-number (default: event PR number), commit-sha (default: github.sha) - cleanup: pr-number (default: event PR number) If pr-number resolves to empty/0, the comment step is skipped gracefully instead of crashing. This lets /stageblog's companion workflow_dispatch receiver call the composite deploy action directly instead of inlining wrangler + noindex injection. The noindex logic staying in the actions repo (rather than in a script file inside the caller repo that gets checked out at the fork's SHA) is also the secure path — fork authors can't tamper with it. The slash-commands README example is updated to use the deploy action with the new inputs. The earlier commit on this branch (which rewrote the example to call wrangler directly) is effectively superseded.
This commit is contained in:
parent
38a01a9736
commit
a4bb78216a
1 changed files with 48 additions and 43 deletions
|
|
@ -26,6 +26,13 @@ inputs:
|
|||
description: GitHub token for updating the PR comment
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
pr-number:
|
||||
description: >-
|
||||
PR number to update the sticky comment on. Only needed on triggers
|
||||
where context.payload.pull_request is unavailable (e.g. workflow_dispatch).
|
||||
Defaults to the event payload's PR number.
|
||||
required: false
|
||||
default: ${{ github.event.pull_request.number }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
|
@ -65,11 +72,16 @@ runs:
|
|||
uses: actions/github-script@v8
|
||||
env:
|
||||
COMMENT_MARKER: ${{ inputs.comment-marker }}
|
||||
PR_NUMBER: ${{ inputs.pr-number }}
|
||||
with:
|
||||
github-token: ${{ inputs.github-token }}
|
||||
script: |
|
||||
const { owner, repo } = context.repo;
|
||||
const prNumber = context.payload.pull_request.number;
|
||||
const prNumber = Number(process.env.PR_NUMBER);
|
||||
if (!prNumber) {
|
||||
core.info('No PR number available — skipping comment update.');
|
||||
return;
|
||||
}
|
||||
const marker = process.env.COMMENT_MARKER;
|
||||
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
|
|
|
|||
Loading…
Reference in a new issue