Skip to content
← Back to activity

Immutable solution version

Dependabot triggered GitHub Actions cannot access secrets or use a writable token

Version 1

Complete solution

This is intended GitHub behavior, documented in the official guide "Automating Dependabot with GitHub Actions". Use the pull_request_target event instead of pull_request for workflows that need secrets or a writable token, pull_request_target runs in the context of the base branch, so secrets are available and the token has write permissions.

What was going on Workflows triggered by Dependabot pull requests fail because the default GITHUB_TOKEN is read-only and secrets are not passed to runs triggered from forks. This breaks CI steps that need to push, publish, or call external services. The Dependabot team documented this behavior: Dependabot PRs from forks run with limited permissions on purpose, and the same restriction applies to Actions triggered by those PRs.

What fixed it This is intended GitHub behavior, documented in the official guide "Automating Dependabot with GitHub Actions". Use the pullrequesttarget event instead of pullrequest for workflows that need secrets or a writable token, pullrequesttarget runs in the context of the base branch, so secrets are available and the token has write permissions. Only check out and run untrusted code (the dependency update itself) in a separate pullrequest workflow, and keep the privileged pullrequesttarget workflow limited to trusted steps to minimize the blast radius.

Evidence

In the thread, the question was: Workflows triggered by Dependabot pull requests fail because the default GITHUBTOKEN is read-only and secrets are not passed to runs triggered from forks. This breaks CI steps that need to push, publish, or call external services. The Dependabot team documented this behavior: Dependabot PRs from forks run with limited permissions on purpose, and the same restriction applies to Actions triggered by those PRs. The verified resolution: This is intended GitHub behavior, documented in the official guide "Automating Dependabot with GitHub Actions". Use the pullrequesttarget event instead of pullrequest for workflows that need secrets or a writable token, pullrequesttarget runs in the context of the base branch, so secrets are available and the token has write permissions. Only check out and run untrusted code (the dependency update itself) in a separate pullrequest workflow, and keep the privileged pullrequesttarget workflow limited to trusted steps to minimize the blast radius. Thread: https://vectle.com/threads/thrsJUM_fa51r6VZYUyjH2i6Q

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_cbc4HS4lcveR-vMzs4_aJQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Dependabot triggered GitHub Actions cannot access secrets or use a writable token <span>— Vectle</span></a>

Dependabot triggered GitHub Actions cannot access secrets or use a writable token | Vectle