checkout: Upgrading @v1.2 -> @v2 can no longer specify short sha in ref
when upgrading to @v2 or later it no longer accepts a single short sha for the ref parameter, and the git command fails:
Setup
uses: actions/checkout@v2.2.0
with:
ref: 7daa143
Output:
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=5 origin +refs/heads/7daa143*:refs/remotes/origin/7daa143* +refs/tags/7daa143*:refs/tags/7daa143*
The process '/usr/bin/git' failed with exit code 1
Waiting 18 seconds before trying again
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 24
- Comments: 15 (3 by maintainers)
Commits related to this issue
- nedgradere checkout action till v1 Ikke støtte før short sha ref i v2 per https://github.com/actions/checkout/issues/265 — committed to navikt/k9-sak-web by albrektsson 3 years ago
- nedgradere checkout action till v1 (#2795) Ikke støtte før short sha ref i v2 per https://github.com/actions/checkout/issues/265 — committed to navikt/k9-sak-web by albrektsson 3 years ago
- Tag the full SHA not the short SHA GitHub's [Checkout action][1] needs the [full SHA in order to checkout a commit][2]. To get the full SHA we simply use a [bash array][3] which outputs its first el... — committed to agilepathway/available-pets-consumer by johnboyes 3 years ago
- Tag the full SHA not the short SHA (#46) GitHub's [Checkout action][1] needs the [full SHA in order to checkout a commit][2]. To get the full SHA we simply use a [bash array][3] which outputs its... — committed to agilepathway/available-pets-consumer by johnboyes 3 years ago
Isn’t is a chicken and egg problem? How can you run git rev-parse before checkout?
What I’m failing to grasp here is the notion that this is somehow an enhancement, when it seems like a regression: this was a part of functionality that was working and is now not working. Unless there was a deliberate design decision to remove short hashes from acceptable inputs (and I certainly haven’t done enough digging to ascertain as much), I don’t think this issue can accurately be characterized as a feature request.
I just ran into this, and worked around it by using
gh
to resolve a short SHA to a full SHA (without checking out the repository), then passing the full SHA toactions/checkout
:(source)
Note that:
gh
requires aGH_TOKEN
secret (docs).In my case, another workflow was calling this one, and passing the short SHA; I also needed
secrets: inherit
at the call-site:(source)
Adding some more info here.
I have a set of steps like:
That resu
This ends up trying to issue the command:
Notice that the short ref is being quoted in the command. I don’t know if that matters or not, but it’s definitely failing. Switching back to
@v1
works.tnx, fetch-depth: 0 doesn’t make any difference, just got a different error. but full sha works. Seems the checkout command it generates assumes it’s a branch or tag when it’s a short hash (7 chars) and thereafter generates an invalid checkout command
With a full sha it generrates this checkout command - same as it should be if a short sha had been treated the same /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +7daa1431d70a06da41e2da7f2ade272bee3d56ca:refs/remotes/pull/515/merge