Repository navigation
fix(publish-preview-oidc): support dispatching previews by pull request or branch - #323
Merged
Merged
Conversation
NPM rejects trusted publishing tokens from `issue_comment` events, so the OIDC variant cannot publish when a comment triggers it. Add a `pull-request` input to `publish-preview-oidc.yml` and `prepare-preview.yml` so a `workflow_dispatch` caller can pass the number instead of relying on `github.event.issue.number`. In `prepare-preview.yml` the input is optional and falls back to the issue number, so `publish-preview.yml` keeps working unchanged. React to the trigger comment only when there is one, and make `build-preview` depend on the fork check directly so it still runs when the reaction is skipped.
Add a `branch` input to `publish-preview-oidc.yml` and `prepare-preview.yml` as an alternative to `pull-request`, so a `workflow_dispatch` caller can publish a preview without a pull request. Exactly one of the two is required. The workflow validates the branch name with `git check-ref-format`, resolves it to a commit once, and checks out that commit, so a push during the run cannot change what gets built. Only branches in this repository are accepted. Other refs, such as `refs/pull/N/head` or raw SHAs, could point at fork code and bypass the fork check. The preview build message is now always appended to `$GITHUB_STEP_SUMMARY`. The pull request comment is only posted when `pull-request` is set.
Mrtenz
marked this pull request as ready for review
November 13, 2026 15:03
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8d2d060. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Explanation
NPM rejects trusted publishing tokens from
issue_commentevents, as it already does forpull_request_target. The OIDC variant (publish-preview-oidc.yml) therefore can't publish when a comment triggers it. Publishing needs a permitted event such asworkflow_dispatch, and the workflows currently read the pull request number fromgithub.event.issue.number, which doesn't exist there.This adds a
pull-requestinput. It is optional inpublish-preview-oidc.yml, so aworkflow_dispatchcaller can pass the number as an input. Inprepare-preview.ymlit falls back togithub.event.issue.number, sopublish-preview.ymlkeeps working unchanged forissue_commentcallers.It also adds a
branchinput for publishing a preview without a pull request. Exactly one ofpull-requestandbranchis required, andprepare-preview.ymlfails early otherwise. The branch name is validated withgit check-ref-format, resolved to a commit once, and that commit is checked out, so a push during the run can't change what gets built. Only branches in this repository are accepted. Other refs, such asrefs/pull/N/heador raw SHAs, could point at fork code and bypass the fork check.The preview build message is now always appended to
$GITHUB_STEP_SUMMARY, and the pull request comment is only posted whenpull-requestis set. That gives branch runs somewhere to show the output.Note
Medium Risk
Changes CI checkout and fork-gating behavior for preview builds, including branch-only paths that bypass fork checks by design.
Overview
OIDC preview publishing can now be triggered via
workflow_dispatch(or similar) by passing either apull-requestnumber or a repobranch, instead of relying ongithub.event.issue.numberfrom comment-triggered events.prepare-preview.ymlgains optionalpull-requestandbranchinputs with mutual-exclusion validation (and branch name checks). Branch runs resolve the tip commit once withgit ls-remoteand check out that SHA detached so mid-run pushes don’t change the build; fork checks are skipped for branch-only runs. The build job no longer waits on comment reactions, and the 👍 reaction step only runs when a comment triggered the workflow.publish-preview-oidc.ymlforwards the new inputs, always writes the preview package list to the job summary, and posts a PR comment only whenpull-requestis set. Existingissue_commentcallers can keep omittingpull-requestand still usegithub.event.issue.numbervia the fallback.Reviewed by Cursor Bugbot for commit 8d2d060. Bugbot is set up for automated code reviews on this repo. Configure here.