1

In my Github Action, I need to clone another repo on the same branch as the one that triggered the workflow.

So if that was a push to master, then I need to clone the remote repo on the master branch.

And if it was a pull request from the feature/xxx-yyy branch, I need to symmetrically clone the remote repo on the feature/xxx-yyy branch.

I reckon I can use ${GITHUB_HEAD_REF} in the case of pull_request, but it seems it won't work with push.

      - uses: actions/checkout@v3
        with:
          repository: 'my-org/e2e-tests'
          ref: ${GITHUB_HEAD_REF}
          token: '${{ secrets.CI_PAT }}'
          path: 'e2e'

Any bits of advice on how to do that?

lessless
  • 23
  • 1
  • 5
  • 2
    Does this answer your question? [How to get the current branch within Github Actions?](https://stackoverflow.com/questions/58033366/how-to-get-the-current-branch-within-github-actions) – Salil Mishra May 21 '22 at 00:38

0 Answers0