-
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
provide git commit hash in outputs #209
Comments
I'm not opposed to adding, but curious more info about the scenario? Including the SHA in the cache key seems wrong since it will change every run. I'm thinking of scenarios like npm. Restoring from cache will cover most packages, even when some packages change between runs. The branch seems like a better approach (e.g master vs legacy). Workaround today is the set-output command. Something like |
Sure, here’s the scenario: We need to build the protobuf repo as part of CI for a protoc plugin. To run the conformance test. We want to follow master on the protobuf repo because they add new tests all the time. The CI workflow is happening inside a docker image provided by the Swift project which has an old version of git so the checkout action is using the http api instead of git, so we can’t run git rev-parse (I tried this first). If I use the branch name in the cache key then we potentially miss updates to the protobuf conformance test until the cache expires. |
@toffaletti thanks that helps! Here is a workaround to determine the SHA, and then pass the same SHA into the checkout step: steps:
- id: get-sha
run: |
echo ::set-output name=sha::$( curl -u "u:${{github.token}}" https://api.github.com/repos/some-owner/some-repo/git/ref/heads/master | jq .object.sha | tr -d '"' )
- uses: actions/checkout@v2
with:
ref: ${{ steps.get-sha.outputs.sha }} |
I second the idea of this feature. In my use case we checkout many repos to build them and do some integration testing. Having the sha in the output will simplify caching some intermediate build steps. |
In my use case i checkout another branch and I want the commit sha for surefire-report |
I would like to use the SHA to tag docker images. If I am reading this correctly, I could do that with this feature. |
This would also be valuable to us on being able to grab the SHA of the container build on merge (HEAD^1) |
can one run a shell script and output the last tag + the number of commits since the last tag, to have a notion of "newer" + the sha to have a clear reference to the source code without tag, sample output would be 1.7.94-57-g2167aa34 or 1.7.94.r57.g2167aa34: ´´´ |
Particularly useful for cases where an arbitrary tag is being checked out (manual workflow dispatch, for instance), and then the revision is getting used elsewhere: opencontainers spec suggests putting
|
I want to second this, scenario here is similar to @toffaletti is saying. Checkout some release/master branch of dependency but only rebuild the dependency if that commit has changed. Or is there an action that allows querying a commit id for a git repository? |
For all the reasons listed above, it would be a great feature to add. |
Keeping this thread alive. My team also uses commit SHAs to tag Docker images in ECR. |
It would be helpful for creating cache keys if we could get the exact commit hash of a ref that might float like 'master'.
The text was updated successfully, but these errors were encountered: