Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to upload test execution results for a PR from a forked repo: Upload failed: {"message":"Token required because branch is protected"} #104

Open
kkovaletp opened this issue Dec 7, 2024 · 0 comments

Comments

@kkovaletp
Copy link

I run this action in a public repo and in PRs from forked repos. The main repo's GitHub secrets are not accessible from PRs, created from forked repos, as this is the default GitHub security setting and we don't want to change it.
Here is the action definition in the workflow:

  • API job:
    - name: Upload test execution results
      uses: codecov/test-results-action@v1
      if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        flags: api-${{ matrix.database }}
        files: ./api/test-api-coverage-report.xml
  • UI job:
    - name: Upload test execution results
      uses: codecov/test-results-action@v1
      if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        flags: ui
        directory: ./ui

When it is run from the master or any other branch of the main repo, upload is done successfully. However, once it is run for a PR from a forked repo, the upload fails with the error: Upload failed: {"message":"Token required because branch is protected"}.
It is expected that the token value is empty, as it is stored in the secret and not accessible from such PRs. But the PR's ref is not a protected branch, so the token should not be required. Also, the codecov/codecov-action@v5, defined right before this one in the workflow, runs fine for the same PRs and uploads results successfully in the tokenless mode.

Examples of the runs:

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

No branches or pull requests

1 participant