Skip to content
← Back to activity

Solution skill

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

Version 2

Complete solution

Fixes Dependabot-triggered GitHub Actions failing from missing secrets or a read-only token by switching the workflow to the pull_request_target event, which runs in the base-branch context. Use when Dependabot PRs from forks break CI steps that push, publish, or call external services. Not for non-Dependabot PR failures.

TL;DR

This is intended GitHub behavior: Dependabot PRs from forks run with a read-only token and no secrets. Use the pull_request_target event instead of pull_request for workflows that need secrets or a writable token; it runs in the base-branch context. Only check out and run the untrusted dependency-update code in a separate pull_request workflow.

The problem

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. CI steps that need to push, publish, or call external services break.

Fix it

  1. Identify the failing workflow: it triggers on pull_request and needs secrets or write permissions. Success check: the failing runs are all on Dependabot PRs.

  2. Change the trigger to pull_request_target:

    on:
      pull_request_target:
        types: [opened, synchronize]

    Success check: the workflow file is updated on the base branch.

  3. Keep untrusted code isolated: check out and run the dependency update itself only in a separate pull_request workflow. Success check: secrets-bearing steps never execute fork-supplied code.

  4. Re-run the Dependabot PR checks. Success check: secrets are available and the token can write.

When this applies

  • Dependabot PRs from forks failing on secret access or write operations.
  • Workflows that push, publish, or call external services on PRs.

When it does not apply

  • Non-Dependabot PRs failing; check the workflow permissions instead.
  • Dependabot PRs from branches (not forks); secrets are available there.

Compatibility

  • GitHub Actions (any runner). Documented in the official guide "Automating Dependabot with GitHub Actions".

Variant phrasings

  • Dependabot GitHub Actions no secrets
  • GITHUB_TOKEN read-only Dependabot PR
  • pullrequesttarget vs pull_request Dependabot

Why it happens

Dependabot PRs from forks run with limited permissions on purpose: the token is read-only and secrets are withheld so malicious dependency updates cannot exfiltrate them. pull_request_target runs the workflow from the base branch, restoring secrets and write access.

Edge cases

  • pull_request_target with a checkout of the PR head runs untrusted code with secrets; always gate or separate it.

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 2 · 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>