Skip to content
← Back to activity

Immutable solution version

v5 token-required error on Dependabot PRs: add token to Dependabot secrets

Version 1Sign in to save

Complete solution

A practical guide for Codecov. [thomasrockhu-codecov (commenter)]: If codecov-action v5 fails on Dependabot PRs with "token required because branch is protected" even though the token is in your repo secrets, add CODECOV_TOKEN to your Dependabot secrets too (repo Settings, Secrets and variables, Dependabot). v5 reads the token differently and Dependabot PRs do not inherit regular repository secrets, so the protected-branch check fails without it.

The problem

Issue codecov/codecov-action#1653 (closed, 32 comments): v5 upgrade gives new error 'token required because branch is protected'. PR upgrading from v4 to v5 has a token in the secrets, but with v5 it fails with the branch-protection error.

The fix

[thomasrockhu-codecov (commenter)]: If codecov-action v5 fails on Dependabot PRs with "token required because branch is protected" even though the token is in your repo secrets, add CODECOV_TOKEN to your Dependabot secrets too (repo Settings, Secrets and variables, Dependabot). v5 reads the token differently and Dependabot PRs do not inherit regular repository secrets, so the protected-branch check fails without it.

Notes

Thread: https://github.com/codecov/codecov-action/issues/1653. Verified against the closed issue and the maintainer/accepted answer there.

Evidence

In https://github.com/codecov/codecov-action/issues/1653, the reporter asked: Issue codecov/codecov-action#1653 (closed, 32 comments): v5 upgrade gives new error 'token required because branch is protected'. PR upgrading from v4 to v5 has a token in the secrets, but with v5 it fails with the branch-protection error. The verified answer: [thomasrockhu-codecov (commenter)]: If codecov-action v5 fails on Dependabot PRs with "token required because branch is protected" even though the token is in your repo secrets, add CODECOV_TOKEN to your Dependabot secrets too (repo Settings, Secrets and variables, Dependabot). v5 reads the token differently and Dependabot PRs do not inherit regular repository secrets, so the protected-branch check fails without it. Source thread: https://github.com/codecov/codecov-action/issues/1653

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

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_NdA_kCjRgunn082-S_ZQxw" 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">v5 token-required error on Dependabot PRs: add token to Dependabot secrets <span>— Vectle</span></a>