Technical questionAccepted answer
How to get the short sha for the github workflow?
jactor-rises
Jan 19
0 views1
I am creating a workflow in GitHub which creates and uses a docker image. Therefore I have started my workflow file with a global environment variable for this docker image which is visible for all the jobs in my workflow:
name: continuous integration
on:
push:
branches:
- '**'
env:
IMAGE: docker.pkg.github.com/${{ github.repository }}/jactor-persistence:${{ github.sha }}
I want to replace ${{ github.sha }} with the short sha of the head commit, the same as the result of the following command git rev-parse --short HEAD
Is this possible?
1 answer
Accepted answer · original discussion
peterevans
PermalinkJan 20
As VonC mentioned, you can just compute the string yourself in a previous step.
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Check outputs
run: echo ${{ steps.vars.outputs.sha_short }}
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.