fix(ci): use GH App token for release PR job to trigger CI naturally#252
Merged
Conversation
Deploying archgate-cli with
|
| Latest commit: |
325182b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://88fdf3c0.archgate-cli.pages.dev |
| Branch Preview URL: | https://fix-release-pr-status-checks.archgate-cli.pages.dev |
The `pull-request` job passed `GITHUB_TOKEN` to simple-release-action. GitHub mutes downstream events on `GITHUB_TOKEN`-authored pushes, so `pull_request` synchronize never fired on the release PR — leaving `Lint, Test & Check` orphaned and the PR blocked on a missing required status check (recurrence after the workaround in #131). Generate a GitHub App installation token in the job and pass it to both `actions/checkout` and `simple-release-action`. App-authored pushes trigger `pull_request` events naturally, so code-pull-request and dco workflows run on `refs/pull/N/head` and produce the required checks. The manual `gh workflow run` / `gh api .../statuses` workaround is removed; job permissions narrowed to `contents: read`. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
c4397e1 to
325182b
Compare
Merged
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.
Summary
Lint, Test & Checkwas missing from the PR rollup).workflow_dispatch+ manual commit-status workaround introduced in #131 with the proper fix: use a GitHub App installation token sosimple-release-action's push triggerspull_requestevents naturally.pull-requestjob permissions tocontents: read(the App token carries the writes).Root cause
release.yml'spull-requestjob was passing${{ github.token }}(the defaultGITHUB_TOKEN) tosimple-release-action. GitHub intentionally suppressespush/pull_requestevents onGITHUB_TOKEN-authored pushes to prevent workflow recursion. As a result:pull_request(synchronize) event fired on the release PR.code-pull-request.yml(Lint, Test & Check, smoke tests) anddco.ymlnever ran onrefs/pull/N/head.gh workflow run code-pull-request.yml --ref releaseand postingValidate Code/DCO Sign-off Checkas commit statuses. But thoseworkflow_dispatchruns land onhead_branch: releasewithpull_requests: []— their check runs are not associated with the PR ref, so branch protection treatedLint, Test & Checkas missing on the PR.Fix
In the
pull-requestjob:actions/create-github-app-tokenusingsecrets.GH_APP_APP_ID/secrets.GH_APP_PRIVATE_KEY(same pattern thecheckandreleasejobs already use).actions/checkoutandsimple-release-action.Run CI and set status checks on release PRstep —code-pull-request.ymlanddco.ymlnow run naturally on the synchronize event.actions: write / contents: write / pull-requests: write / statuses: writetocontents: read.App-token-authored pushes DO trigger downstream workflow events, so the full set of required checks now appears on
refs/pull/N/headand branch protection accepts them.Note about #251
This fix only takes effect for future release PRs (e.g., 0.31.2). PR #251 itself still has the orphaned check problem and needs to be admin-merged or recreated by closing it and pushing a new commit to
main.Test plan
main(any user-visible change) and confirmsimple-release-actionopens a release PR whose head SHA showsValidate Code,Lint, Test & Check, smoke tests, andDCO Sign-off Checkall under the PR ref (not just on the commit).mergeStateStatusis no longerBLOCKEDfor missing required checks (review requirement still applies, as expected).pull-requestjob logs show the App token being generated and theCreate or update pull requeststep using it.