Skip to content

Run CI on the "Version Packages" PR - #136

Merged
louisbels merged 1 commit into
mainfrom
ci/release-app-token
Jul 26, 2026
Merged

Run CI on the "Version Packages" PR#136
louisbels merged 1 commit into
mainfrom
ci/release-app-token

Conversation

@louisbels

Copy link
Copy Markdown
Member

The gap

GitHub suppresses pull_request events for anything done with the default GITHUB_TOKEN, so workflows cannot trigger themselves. The "Version Packages" PR that changesets opens is created that way — so it carries no CI at all.

You saw it on #135: 3 CodeQL checks, and nothing else. No lint, no typecheck, no tests, no e2e, no SDK package check. It merged to main — the branch that deploys to production and publishes to npm — unverified.

That is benign today, because the PR only bumps a version and writes a CHANGELOG. But nothing enforces that it stays that way.

The fix

release.yml now mints a short-lived token from a GitHub App and uses it for both the checkout and changesets/action. The PR then comes from a distinct identity, and the checks run normally.

The App needs exactly two repository permissions: Contents (read/write) and Pull requests (read/write).

Both uses fall back to GITHUB_TOKEN when APP_ID is absent:

token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}

So forks and any setup without the App keep releasing exactly as they do now — they simply don't get CI on the version PR. Nothing breaks if the secrets are missing or the App is uninstalled later.

Required configuration

This PR is inert until the two secrets exist. Setup is in CONTRIBUTING.md; the short version:

  1. Create a GitHub App (no webhook), permissions Contents: read/write + Pull requests: read/write
  2. Install it on largerio/secret, generate a private key
  3. Add secrets APP_ID and APP_PRIVATE_KEY

Verifying it worked

The next release cycle is the test: the "Version Packages" PR should show the full check suite instead of CodeQL alone, and be authored by the App rather than github-actions[bot].


Also note @largerio/secret-sdk@1.1.0 published cleanly from #134/#135. I pulled the tarball back from the registry to confirm: README and LICENSE present, exports resolved through publishConfig, and zero imports of a private workspace package in the shipped .d.ts — the bug that made the previous release unusable from TypeScript.

GitHub suppresses `pull_request` events for anything done with the default
GITHUB_TOKEN, to avoid workflows triggering themselves. The version PR that
changesets opens is created that way, so it carried no CI at all: lint,
typecheck, tests, e2e and the SDK package check were all skipped, and it merged
to main unverified.

That is benign while the PR only bumps a version and writes a CHANGELOG — which
is all it does today — but nothing enforces that, and main is the branch that
deploys and publishes.

The workflow now mints a short-lived token from a GitHub App and uses it for
both the checkout and changesets/action, so the PR comes from a distinct
identity and the checks run. The App needs only Contents and Pull requests,
both read/write.

Both uses fall back to GITHUB_TOKEN when APP_ID is absent, so forks and any
setup without the App keep releasing exactly as before — they just don't get
CI on the version PR. Documented in CONTRIBUTING.
@louisbels
louisbels merged commit 1e3d8ba into main Jul 26, 2026
11 checks passed
@louisbels
louisbels deleted the ci/release-app-token branch July 26, 2026 11:05
louisbels added a commit that referenced this pull request Jul 26, 2026
#136 left `release.yml` unparseable: `secrets` is not among the contexts
available to a step-level `if`, so GitHub rejected the whole file. The failure
is quiet — the run reports "failure" with **zero jobs**, and the workflow list
shows the file path instead of its name. Releases would have stopped working
silently at the next changeset.

Resolving the secret at job level fixes it: `secrets` *is* available in
`jobs.<id>.env`, and `env` is available to a step `if`.

Added actionlint to the `check` chain, verified against the exact bug:

  release.yml:45:17: context "secrets" is not allowed here. available
  contexts are "env", "github", "inputs", "job", "matrix", "needs",
  "runner", "steps", "strategy", "vars"

A broken workflow file is the one class of CI failure the CI itself cannot
report, which is what made this worth a gate of its own rather than more care.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant