Blog
Get the Short SHA of a Commit in GitHub Actions
, John Comber
Introduction
This example shows how to get the short GitHub SHA of a commit and set an environment variable in GitHub Actions.
Code
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get Short GitHub SHA and Save in Environment Variable
run: echo "SHORT_GITHUB_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV