checkout: Cannot use parent specifiers in the ref

I’d like to run an action on a pull_request and check out the actual content of the PR, not a merge with master (because I want it to run even if there is a merge conflict among other reasons). Support for specifying this has been requested on the community forum.

I’ve tried the following:

with:
  ref: ${{ github.ref }}^2

Which causes a failure because it tries to do:

 git fetch --tags --prune --progress --no-recurse-submodules origin +refs/heads/*:refs/remotes/origin/* +refs/pull/3/merge^2:refs/remotes/pull/3/merge^2

which is an invalid refspec.

Doing this seems to just get completely ignored:

with:
  ref: ${{ github.sha }}^2

I haven’t found a way to use $GITHUB_SHA yet either (it seems to be used literally when in a with block).

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@mrrobot47 thanks. also note, the first option is a race condition because the PR can be updated before the job starts (ref update)

@peter-evans sorry its refs/remotes/pull/###/head or pull/###/head

i played around with this locally by fetching everything under pull:

git fetch origin '+refs/pull/*:refs/remotes/pull/*'
git branch --list --remote
git log refs/remotes/pull/70/head