checkout icon indicating copy to clipboard operation
checkout copied to clipboard

SHA checkout is not working via `ref:`

Open 7AC opened this issue 2 years ago • 5 comments

I have the following config:

    - uses: actions/checkout@v3
      with:
        repository: polymerdao/prysm
        ref: 2d05a698ef9d9a082eee80a9c37a4c046de1a189

It translates to the following which doesn't work:

Fetching the repository
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/2d05a698ef9d9a082eee80a9c37a4c046de1a189*:refs/remotes/origin/2d05a698ef9d9a082eee80a9c37a4c046de1a189* +refs/tags/2d05a698ef9d9a082eee80a9c37a4c046de1a189*:refs/tags/2d05a698ef9d9a082eee80a9c37a4c046de1a189*
  The process '/usr/bin/git' failed with exit code 1
  Waiting 13 seconds before trying again
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/2d05a698ef9d9a082eee80a9c37a4c046de1a189*:refs/remotes/origin/2d05a698ef9d9a082eee80a9c37a4c046de1a189* +refs/tags/2d05a698ef9d9a082eee80a9c37a4c046de1a189*:refs/tags/2d05a698ef9d9a082eee80a9c37a4c046de1a189*
  The process '/usr/bin/git' failed with exit code 1
  Waiting 14 seconds before trying again
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/2d05a698ef9d9a082eee80a9c37a4c046de1a189*:refs/remotes/origin/2d05a698ef9d9a082eee80a9c37a4c046de1a189* +refs/tags/2d05a698ef9d9a082eee80a9c37a4c046de1a189*:refs/tags/2d05a698ef9d9a082eee80a9c37a4c046de1a189*
  Error: The process '/usr/bin/git' failed with exit code 1

7AC avatar May 11 '23 21:05 7AC

same here

qxmips avatar Jun 07 '23 07:06 qxmips

It works for v2 but is broken for v3.

jessicaxiejw avatar Jun 08 '23 19:06 jessicaxiejw

Seems like this is working in v4:

Checking out the ref
  /usr/bin/git checkout --progress --force cb8c0fc06f38f9654cffb81401c0161360f27407
  Note: switching to 'cb8c0fc06f38f96[54](https://github.com/psychobolt/vite-storybook-boilerplate/actions/runs/7253475231/job/19760149044#step:2:61)cffb81401c0161360f27407'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by switching back to a branch.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -c with the switch command. Example:
  
    git switch -c <new-branch-name>
  
  Or undo this operation with:
  
    git switch -
  
  Turn off this advice by setting config variable advice.detachedHead to false
  
  HEAD is now at cb8c0fc Update typescript-eslint monorepo to v6.15.0 (#241)
/usr/bin/git log -1 --format='%H'
'cb8c0fc06f38f9654cffb81401c01613[60](https://github.com/psychobolt/vite-storybook-boilerplate/actions/runs/7253475231/job/19760149044#step:2:67)f27407'

It only checkouts in a detached state which you can check using this condition:

      - name: Get branch name
        id: ref
        run: echo "name=$(git branch --show-current)" >> $GITHUB_OUTPUTS
      - if: ${{ steps.ref.outputs.name == '' }} # if detached
        run: # do something!

psychobolt avatar Dec 18 '23 21:12 psychobolt

It's not working in v4.

image

The workaround is to follow up the action with a run step that checks out the commit.

Milo-Kerr-ICS avatar Feb 15 '24 18:02 Milo-Kerr-ICS