Skip to content

Commit b976796

Browse files
committed
Add short commit SHA as a Docker image tag in CI workflow
1 parent c7b292c commit b976796

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ jobs:
3535
username: ${{ github.actor }}
3636
password: ${{ secrets.GITHUB_TOKEN }}
3737

38+
# First 8 characters of the commit hash, used as an image tag.
39+
- name: Short commit SHA
40+
id: vars
41+
run: echo "short_sha=${GITHUB_SHA:0:8}" >> "$GITHUB_OUTPUT"
42+
3843
- name: Docker metadata
3944
id: meta
4045
uses: docker/metadata-action@v5
@@ -45,6 +50,7 @@ jobs:
4550
type=ref,event=branch
4651
type=ref,event=tag
4752
type=sha
53+
type=raw,value=${{ steps.vars.outputs.short_sha }}
4854
type=raw,value=latest,enable={{is_default_branch}}
4955
5056
# The Dockerfile runs `mvn install` (install the deps and build in the image build),

0 commit comments

Comments
 (0)