Repository navigation
feat(publish-preview): add OIDC variant of the workflow - #311
Conversation
GitHub Actions `permissions` cannot be set dynamically, and a reusable workflow that declares `id-token: write` forces every caller to grant it, even when the job is skipped. Add `publish-preview-oidc.yml`, which grants `id-token: write` and publishes without an npm token. Callers pick the file that matches their authentication mode. `publish-preview.yml` stays token-only and keeps its narrower permissions. Move the `is-fork-pull-request`, `react-to-comment`, and `build-preview` jobs into a shared `publish-preview-build.yml` workflow that both workflows call, so the build logic isn't duplicated.
| secrets: | ||
| BUILD_ENV: ${{ secrets.BUILD_ENV }} | ||
|
|
||
| publish-preview: |
There was a problem hiding this comment.
We could share more with publish-preview.yml here if we move this logic into a composite action. Unsure if it's worth the effort, though.
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 7146735. Configure here.
A reusable workflow call reports success when its inner jobs are skipped. After the build moved into `publish-preview-build.yml`, fork pull requests skipped `build-preview`, but the `build` call still succeeded. `publish-preview` then ran, found no `preview-build-artifacts`, and failed. The build workflow now exposes an `is-fork` output, and `publish-preview` only runs when it is `false`, in both `publish-preview.yml` and `publish-preview-oidc.yml`.
There was a problem hiding this comment.
Nit: Should we call this prepare-preview.yml or build-preview.yml? In docs and elsewhere I've been using "preview build" as an alias for "preview version", so this could be misinterpreted as the workflow that runs the publish step.
Or did you want to make sure all of the preview build files were grouped together alphabetically?
There was a problem hiding this comment.
I did it for alphabetical grouping yes, but can rename it.
There was a problem hiding this comment.
Well, it's still grouped (for now) when we name it prepare-preview.yml, so I guess it's fine.
| if: ${{ inputs.is-monorepo && !inputs.dry-run }} | ||
| run: yarn workspaces foreach --no-private --all exec yarn npm publish --tag preview | ||
| env: | ||
| YARN_NPM_REGISTRY_SERVER: 'https://registry.npmjs.org' |
There was a problem hiding this comment.
Looks like the only differences between this workflow and publish-preview.yml is that 1) we set the id-token: true permission and 2) we no longer pass YARN_NPM_AUTH_TOKEN to the publish steps. Does that sound right?
There was a problem hiding this comment.
Yes, that's right.
We can't conditionally set permissions, so we have to copy this, unfortunately.
| build: | ||
| name: Build |
There was a problem hiding this comment.
Should this be named differently matching the composite action name?
There was a problem hiding this comment.
I thought naming it "Build" was fine, since that's what prepare-preview does. Can rename if you prefer.
|
|
||
| - name: Publish preview builds (monorepo) | ||
| if: ${{ inputs.is-monorepo && !inputs.dry-run }} | ||
| run: yarn workspaces foreach --no-private --all exec yarn npm publish --tag preview |
There was a problem hiding this comment.
Should we do --provenance?
There was a problem hiding this comment.
We trigger this workflow from pull request comments, which runs the workflow from main, so provenance would point to the wrong branch.
It also doesn't provide much benefit for preview builds in general, I think.

Explanation
GitHub Actions
permissionscan't be set dynamically, and a reusable workflow that declaresid-token: writeforces every caller to grant it, even when the job is skipped. Anoidcinput can't make the permission optional.This adds
publish-preview-oidc.yml, which grantsid-token: writeand publishes without an npm token. Callers pick the file that matches their authentication mode, sopublish-preview.ymlstays token-only with its narrower permissions.The
is-fork-pull-request,react-to-comment, andbuild-previewjobs move into a sharedpublish-preview-build.ymlworkflow that both workflows call. The publish job stays duplicated because its permissions differ.Note
Medium Risk
Touches NPM publish automation and adds an OIDC publishing path; behavior change is mostly structural, but mistakes could affect preview package publishing or permissions.
Overview
Preview build steps are extracted into a reusable
prepare-preview.ymlworkflow (fork detection, comment reaction, PR checkout, manifest renaming, install/build ordering, and artifact upload) and both publish flows now call it via abuildjob, gating publish withneeds.build.outputs.is-fork.A new
publish-preview-oidc.ymlreusable workflow mirrors the existing token-based publisher but requestsid-token: writeand publishes withoutPUBLISH_PREVIEW_NPM_TOKEN, so consumers can pick OIDC vs secret-based auth without forcing extra permissions on token-only callers.publish-preview.ymlis slimmed down to the shared build plus its existing token-authenticated publish job (unchanged sanitization, publish, and PR comment steps).Reviewed by Cursor Bugbot for commit 67c76e6. Bugbot is set up for automated code reviews on this repo. Configure here.