checkout
checkout copied to clipboard
SHA checkout is not working via `ref:`
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
same here
It works for v2 but is broken for v3.
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!
It's not working in v4.
The workaround is to follow up the action with a run step that checks out the commit.