Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Action fails to upload when using pull_request_target on GitHub

See original GitHub issue

The addition of pull_request_target events allows PRs from forked repos coming into the head repo to utilize some functions that pull_request alone cannot do if PR is coming from a forked repo.

With that in mind the action always fail because GITHUB_REF is the PR Base Branch path (refs/heads/branch name). Is there a way this can be fixed through actions to detect the PR number that actions is running that will also allow usage of pull_request_target?

For the time being I am manually using the bash uploader but manually parsing through the event and extracting the PR number, which I then force the uploader to use it via -P. While this works, there’s nothing shown on that Pull Request from CodeCov unfortunately.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

itaverocommented, Feb 26, 2021

Took a bit of trial and error, but this step seems to work:

      - name: Publish Code Coverage
        uses: codecov/codecov-action@v1
        if: github.event_name == 'pull_request_target'
          override_pr: ${{ github.event.number }}
          override_sha: ${{ github.event.pull_request.head.sha }}
          files: ./coverage/clover.xml
          flags: tests
          fail_ci_if_error: true
RohanNagarcommented, Mar 28, 2021

I think I still need the workaround, I just don’t need the fetch-depth. Doing this worked for me:

- name: Upload Codecov report (pull_request)
  if: startsWith(github.event_name, 'pull_request')
  uses: codecov/codecov-action@v1.3.1
   directory: .
   override_pr: ${{ github.event.number }}
   override_commit: ${{ github.event.pull_request.head.sha }}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Github actions workflow doesn't run on pull request when pull ...
Along with a solution solution: Conversely, workflows with the pull_request_target event will run even if the pull request has a merge conflict.
Read more >
Why doesn't my GitHub Action run automatically from a fork ...
GitHub Actions and Pull Requests with Bdougie#30minutestomergeA quick tour of specific GitHub Actions triggers and their use, plus a deep ...
Read more >
GitHub Actions Security Best Practices [cheat sheet included]
Harden your Action runners (and don't use self-hosted runners for public repositories!) Be extra careful with the pull_request_target trigger ...
Read more >
Github Actions and the threat of malicious pull requests
What this means is, the pull_request_target event does not use anything from the fork PR at all when executing the workflow configured against ......
Read more >
Github Actions POST upload 404 - Codecov
Description Uploads from public repository on Github using Github Actions shows: [2022-07-25T18:41:14.578Z] ['error'] There was an error ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found