'Display actions in fork in the pull request

Long story short, I needed to use pull_request_target because I needed to checkout a private repo and you can't transfer secrets to a fork.

So now, in my .github/workflow.yml file I have the following lines:

on: [push,pull_request_target]

jobs:
  build-and-test:
    runs-on: ubuntu-latest

    steps:
      # Checkout the code of the current branch
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Checkout private repo
        uses: actions/checkout@v2
        with:
          repository: private/repo
          path: './private'
          token: ${{ secrets.MY_PAT }}

The thing is, this will run on my fork's branch, not on the pull request so I can't see directly in the pull request screen if everything is ok.

enter image description here

This is a commit before using pull_request_target, notice the red cross because some checks failed. The second one is a commit after using pull_request_target, I don't even have a cross or check, I need to click on the commit then on my branch then in the actions tab.

Is there a way to push the results from my branch to the pull request on the main repository?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source