Repository navigation
Description
Goal
Publish coverage generated by fork pull requests to Codecov without allowing the privileged workflow_run job to check out or execute fork-controlled code.
Problem
Workflow run 29758909096 failed in Upload Coverage Report (PR) with:
Refusing to check out fork pull request code from a 'workflow_run' workflow.
The unprivileged Generate Coverage Report (PR) workflow correctly creates and stores codecov.json, the PR number, and the head SHA as artifacts. The privileged uploader then checks out the artifact-provided head SHA. actions/checkout@v7 correctly blocks that operation for fork pull requests because the job has the base repository's token, secrets, cache scope, and runner access.
This is not a codecov/codecov-action@v7 regression. The Codecov v6-to-v7 upgrade was committed in 709fbec; the workflow behavior was unchanged. The failure appeared after actions/checkout was upgraded from v6 to v7 in ad647c78, which exposes the existing unsafe checkout.
The two-workflow design originated in 9d8174df for #1075, replacing a single pull_request_target workflow that checked out and executed fork code while it could access CODECOV_TOKEN.
Proposed Fix
- Check out the trusted default branch before retrieving any fork-produced artifacts, satisfying Codecov's documented checkout prerequisite.
- Remove the artifact-provided fork SHA from the checkout configuration.
- Keep downloading the coverage report and metadata artifacts, then pass the explicit report path, pull request number, and commit SHA to Codecov.
- Do not set
allow-unsafe-pr-checkout: true, and do not run or otherwise execute fork-controlled code or artifact content.
Acceptance Criteria
- A fork-originated pull request completes
Upload Coverage Report (PR)and publishes its generated report to Codecov. - The privileged uploader checks out only the trusted default branch before artifact retrieval and never checks out or executes fork-controlled code.
allow-unsafe-pr-checkout: trueis absent.- Codecov receives the generated report with the source pull request number and commit SHA.
- The implementation passes
linter alland relevant workflow validation. - Fork and same-repository pull request paths are manually verified with recorded workflow and Codecov evidence.
References
- Failing workflow: https://github.com/torrust/torrust-tracker/actions/runs/29758909096
- GitHub security guidance: https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target
- Codecov action README: https://github.com/codecov/codecov-action
- A local implementation specification will be tracked in this repository's
docs/issues/open/directory.
Activity
docs(issues): align issue torrust#2006 spec tables
docs(issues): add issue specification for torrust#2006
docs(issues): align issue torrust#2006 spec tables
Merge torrust#2008: fix(ci): upload fork PR coverage safely
Merge #2021: chore(issues): archive closed specs and enforce dual-for…