ci(test): skip test-trigger-other-job when token is read-only#18
Open
bearomorphism wants to merge 1 commit intocommitizen-tools:mainfrom
Open
ci(test): skip test-trigger-other-job when token is read-only#18bearomorphism wants to merge 1 commit intocommitizen-tools:mainfrom
bearomorphism wants to merge 1 commit intocommitizen-tools:mainfrom
Conversation
The test-trigger-other-job job runs `gh workflow run`, which requires
`actions: write` on the GITHUB_TOKEN. The job has been failing on:
- Fork PRs (e.g. contributor PRs from forks): fork-originated PRs
always receive a read-only GITHUB_TOKEN.
- Dependabot PRs (e.g. commitizen-tools#15): even though dependabot creates branches
in the same repo, the dependabot[bot] actor receives a restricted
token by default.
Both produce:
could not create workflow dispatch event: HTTP 403:
Resource not accessible by integration
Skip this job in both cases by gating on `head.repo.full_name` and on
`github.actor`. The job continues to run on PRs from same-repo
branches authored by humans, where the token has the required
permissions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
439b35f to
bc2eb75
Compare
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.
Description
The
test-trigger-other-jobjob in.github/workflows/test.yamlrunsgh workflow run, which requiresactions: writeon theGITHUB_TOKEN. This call fails with HTTP 403 (Resource not accessible by integration) in two cases where the token is read-only:GITHUB_TOKENfor security.dependabot[bot]actor receives a restricted token by default.Examples of the resulting failures:
These permanent failures add noise to PR checks and make it impossible for fork-based or dependabot-driven PRs to get a green CI without maintainer intervention.
Change
Add a guard so the job is skipped when the token will be read-only:
The job continues to run on:
main(nopull_requestcontext)Why not other approaches?
pull_request_targetwould give fork PRs a writeable token — major security risk, not appropriate here.continue-on-error: trueon the trigger step would hide real failures, making the test meaningless.permissions: { actions: write }block does not help: fork and dependabot tokens stay read-only regardless.Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot