Skip to content

ci(test): skip test-trigger-other-job when token is read-only#18

Open
bearomorphism wants to merge 1 commit intocommitizen-tools:mainfrom
bearomorphism:ci/skip-trigger-other-job-on-forks
Open

ci(test): skip test-trigger-other-job when token is read-only#18
bearomorphism wants to merge 1 commit intocommitizen-tools:mainfrom
bearomorphism:ci/skip-trigger-other-job-on-forks

Conversation

@bearomorphism
Copy link
Copy Markdown
Collaborator

@bearomorphism bearomorphism commented May 8, 2026

Description

The test-trigger-other-job job in .github/workflows/test.yaml runs gh workflow run, which requires actions: write on the GITHUB_TOKEN. This call fails with HTTP 403 (Resource not accessible by integration) in two cases where the token is read-only:

  • Fork PRs — fork-originated PRs always get a read-only GITHUB_TOKEN for security.
  • Dependabot PRs — even though the branch is in the same repo, the 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:

test-trigger-other-job:
  runs-on: ubuntu-latest
  if: >-
    github.event.pull_request.head.repo.full_name == github.repository &&
    github.actor != 'dependabot[bot]'
  steps: ...

The job continues to run on:

  • PRs from same-repo branches authored by humans (where the token has the right permissions)
  • Direct pushes to main (no pull_request context)

Why not other approaches?

  • pull_request_target would give fork PRs a writeable token — major security risk, not appropriate here.
  • continue-on-error: true on the trigger step would hide real failures, making the test meaningless.
  • A workflow-level permissions: { actions: write } block does not help: fork and dependabot tokens stay read-only regardless.

Checklist

  • I have read the contributing guidelines

Was generative AI tooling used to co-author this PR?

  • Yes (please specify the tool below)

Generated-by: GitHub Copilot

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>
@bearomorphism bearomorphism force-pushed the ci/skip-trigger-other-job-on-forks branch from 439b35f to bc2eb75 Compare May 8, 2026 08:33
@bearomorphism bearomorphism changed the title ci(test): skip test-trigger-other-job on fork PRs ci(test): skip test-trigger-other-job when token is read-only May 8, 2026
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