Summary
The Book Preview (PR) workflow can build the preview successfully but still fail on fork-origin pull requests when the final actions/github-script step tries to create/update a PR comment.
Observed on dashpay/platform#3092:
Failure mode
The workflow calls github.rest.issues.createComment / updateComment from a pull_request run:
RequestError [HttpError]: Resource not accessible by integration
status: 403
x-accepted-github-permissions: issues=write; pull_requests=write
Current upstream/v3.1-dev:.github/workflows/book-preview.yml grants:
permissions:
contents: read
pull-requests: write
Two problems combine here:
- Issue comments require
issues: write, not just pull-requests: write.
- For PRs from forks, the
pull_request workflow token is read-only anyway, so the comment step cannot be relied on even if workflow permissions are adjusted.
Suggested fix
Do not fail the preview build when the comment cannot be posted. Options:
- guard the comment step to same-repo PRs only, or
- catch 403s in the
github-script and log a warning, or
- mark only the comment step
continue-on-error: true.
Avoid switching this build workflow directly to pull_request_target with write credentials while checking out/building untrusted PR code.
Impact
Any fork PR touching book/** can get a red Build book preview check even though mdbook build book succeeds.
Summary
The
Book Preview (PR)workflow can build the preview successfully but still fail on fork-origin pull requests when the finalactions/github-scriptstep tries to create/update a PR comment.Observed on
dashpay/platform#3092:thepastaclaw/platformPost preview linkFailure mode
The workflow calls
github.rest.issues.createComment/updateCommentfrom apull_requestrun:Current
upstream/v3.1-dev:.github/workflows/book-preview.ymlgrants:Two problems combine here:
issues: write, not justpull-requests: write.pull_requestworkflow token is read-only anyway, so the comment step cannot be relied on even if workflow permissions are adjusted.Suggested fix
Do not fail the preview build when the comment cannot be posted. Options:
github-scriptand log a warning, orcontinue-on-error: true.Avoid switching this build workflow directly to
pull_request_targetwith write credentials while checking out/building untrusted PR code.Impact
Any fork PR touching
book/**can get a redBuild book previewcheck even thoughmdbook build booksucceeds.