What Is GITHUB_SHA?
GITHUB_SHA holds the 40-character commit hash that started the current workflow run.
Every GitHub Actions run is tied to a specific commit. GITHUB_SHA is the default environment variable that exposes that commit SHA, so steps can tag images, label artifacts, or report status against the exact code being built.
What it contains
The full commit SHA. For a pull_request event it is the SHA of a temporary merge commit, not the head of your branch; use ${{ github.event.pull_request.head.sha }} when you need the real head commit.
Using it in CI
Tag a Docker image or name an artifact with the short SHA so every build is traceable.
shell
docker build -t myapp:${GITHUB_SHA::7} .Key takeaways
- GITHUB_SHA is the triggering commit hash.
- On pull_request it is a merge commit SHA, not the branch head.
- Use the short SHA to tag traceable build artifacts.