next.js
682be07b - [cd] Require bot-approved for releases dispatched from release branches (#102437)

Commit
7 hours ago
[cd] Require bot-approved for releases dispatched from release branches (#102437) ### What? Fixes the `environment:` selection in the `Trigger Release` workflow (`.github/workflows/trigger_release.yml`). Before this change, any prerelease (`canary`, `beta`, `preview`, `release-candidate`) dispatched from a `releases/**` branch was rejected before the job started. Now those prereleases use `bot-approved` and wait for approval. | Trigger | Before | After | | --- | --- | --- | | Scheduled nightly | `bot-autonomous` | `bot-autonomous` | | Non-stable dispatched from `canary` | `bot-autonomous` | `bot-autonomous` | | `stable` dispatched from anywhere | `bot-approved` | `bot-approved` | | Non-stable dispatched from `releases/**` | `bot-autonomous` (rejected) | `bot-approved` | ### Why? Dispatching `Trigger Release` from `releases/stable/16-5` with `releaseType: preview` failed before the job started (https://github.com/vercel/next.js/actions/runs/45780990648): > Branch "releases/stable/16-5" is not allowed to deploy to bot-autonomous due to environment protection rules. The job chose `bot-autonomous` for every non-stable release type. But the two environments only accept these refs: - `bot-autonomous` (no reviewers): `canary` branch, `v*` tags - `bot-approved` (required reviewers): `canary`, `v*`, `releases/*`, `releases/**/*` So every prerelease dispatched from a release branch was guaranteed to fail. This came in with #100121 ("[cd] Gate release bot credentials behind GitHub environments"), which was backported in #100123 and #100124. The fix doesn't add `releases/**` to `bot-autonomous`. It routes those runs through `bot-approved`, which keeps #100121's goal that bot credentials only run on code that two people have reviewed. ### How? ```yaml environment: ${{ (github.event_name == 'schedule' || (github.ref_name == 'canary' && inputs.releaseType != 'stable')) && 'bot-autonomous' || 'bot-approved' }} ``` `workflow_dispatch` uses the workflow file from the branch it was dispatched from, so this also needs backports to `releases/stable/16-5`, `releases/lts/active` and `releases/lts/maintenance`. Those are the only release branches that still have the old expression. Other workflows I audited: - Every other `bot-autonomous` job uses a fixed environment and doesn't depend on `releaseType`. `undraftRelease` in `build_and_deploy.yml` runs on `v*` tag pushes, which `bot-autonomous` allows. `sync_backport_canary_release.yml` runs via `workflow_run` on the default branch. The scheduled `update_react`, `update_fonts_data` and `rspack-update-tests-manifest` workflows, and `create_release_branch`, run on `canary`. None of them has this problem. - `publishRelease` in `build_and_deploy.yml` runs on the `v*` tag push, and each `release-*` environment only allows the matching `v*-<channel>.*` / `v*` tag pattern. It doesn't depend on the dispatching branch, so it's unchanged. Reviewer: eps1lon (author of #100121) ### Verification - Confirmed the environment branch policies above with `gh api repos/vercel/next.js/environments/<env>/deployment-branch-policies`. - Checked that the workflow file still parses as YAML (prettier and a YAML parser). - Manual check after merging this and the `releases/stable/16-5` backport (not done yet): 1. Dispatch `Trigger Release` from `releases/stable/16-5` with `releaseType=preview` and `dryRun=true`. 2. Confirm the `start` job waits for `bot-approved` review instead of failing with the environment protection error. 3. Optionally, dispatch `releaseType=canary`, `dryRun=true` from `canary` and confirm it still runs under `bot-autonomous` without approval. <!-- NEXT_JS_LLM --> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Parents
Loading