-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrading @v1.2 -> @v2 can no longer specify short sha in ref #265
Comments
For improved perf, v2 only fetches a single commit by default. If you set |
tnx, With a full sha it generrates this checkout command - same as it should be if a short sha had been treated the same |
Thanks for confirmation. Fyi - I updated the title to clarify "short sha" instead of "single ref" |
Also I marked as enhancement. Adding some thoughts regarding implementation: I wonder if the Also would need to be implemented for the case when git 2.18 not in the PATH, and fallback to download the tarball from the REST API. |
Adding some more info here. I have a set of steps like: - name: Lookup Branch
uses: actions/github-script@v3
id: pr-branch
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
})
return response.data.head.ref
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ steps.pr-branch.outputs.result }}
persist-credentials: false 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 |
Ikke støtte før short sha ref i v2 per actions/checkout#265
Ikke støtte før short sha ref i v2 per actions/checkout#265
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 element. [1]: https://github.com/actions/checkout [2]: actions/checkout#265 [3]: https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays
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 element. [1]: https://github.com/actions/checkout [2]: actions/checkout#265 [3]: https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays
Unsurprisingly this also affects checkout@v3. Reverting back to v1 satisfied my use case as many others have suggested |
same problem, checkout@v2 doesnt support short sha |
For now, as a workaround, I am using
in order to get the full SHA from the short SHA, then passing the full SHA to the checkout action. However, it would be really nice if we could pass in the short SHA directly like we could in v1. |
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. |
Any updates here? This would be a good feature to return. |
Bump +1 - please return this feature, I've had to move back to v1. Totally agree with @socketbox. |
I stumbled on this because I also have a tool that would like to use short SHA's, but like this one it uses If there is a way to do this, please tell me (us). |
I just ran into this, and worked around it by using on:
workflow_dispatch:
inputs:
ref:
type: string
default: main
description: "The branch, tag, or SHA to run the workflow from"
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Resolve inputs.ref to full SHA
id: resolve-ref
# https://github.com/actions/checkout/issues/265
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
ref=${{ inputs.ref }}
sha=$(gh api /repos/$GITHUB_REPOSITORY/commits/$ref | jq -r .sha)
if [ -z "$sha" ]; then
echo "Failed to resolve ref $ref (possibly missing GH_TOKEN env var?)" >&2
exit 1
fi
echo "Expanded ref $ref to SHA $sha"
echo "sha=$sha" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
ref: ${{ steps.resolve-ref.outputs.sha }} (source) Note that:
In my case, another workflow was calling this one, and passing the short SHA; I also needed rebuild_www:
name: Rebuild www
needs: refresh_data
if: needs.refresh_data.outputs.build_www
uses: ./.github/workflows/www.yml
secrets: inherit
with:
ref: ${{ needs.refresh_data.outputs.sha }} (source) |
I also need to be able to checkout via short sha. |
when upgrading to @v2 or later it no longer accepts a single short sha for the ref parameter, and the git command fails:
Setup
Output:
The text was updated successfully, but these errors were encountered: