Skip to content

Commit ef26550

Browse files
committed
More in-depth docker image versioning
1 parent 95586be commit ef26550

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

.github/workflows/docker.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Docker Image CI
22

33
on:
44
push:
5-
branches: ["master"]
5+
branches: ["**"]
66
pull_request:
77
branches: ["master"]
88
workflow_dispatch:
@@ -11,6 +11,11 @@ jobs:
1111
docker-build:
1212
runs-on: ubuntu-latest
1313
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
1419
- name: Login to ghcr.io
1520
uses: docker/login-action@v3
1621
with:
@@ -27,12 +32,35 @@ jobs:
2732
- name: lowercase github.repository
2833
run: echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> ${GITHUB_ENV}
2934

30-
- name: Build and push
35+
- name: Determine version tag
36+
id: version
37+
run: |
38+
VERSION=$(jq -r '.version' package.json)
39+
GIT_TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || echo "")
40+
if [ -z "$GIT_TAG" ]; then
41+
VERSION_TAG="${VERSION}-dirty"
42+
else
43+
VERSION_TAG="${VERSION}"
44+
fi
45+
echo "version_tag=${VERSION_TAG}" >> $GITHUB_OUTPUT
46+
47+
- name: Build and push (master)
48+
if: github.ref == 'refs/heads/master'
3149
uses: docker/build-push-action@v6
3250
with:
3351
file: Dockerfile
3452
push: true
3553
platforms: linux/amd64,linux/arm64
3654
tags: |
3755
ghcr.io/${{ env.IMAGE_NAME }}:latest
38-
ghcr.io/${{ env.IMAGE_NAME }}:${{ github.RUN_ID }}
56+
ghcr.io/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version_tag }}
57+
58+
- name: Build and push (nightly)
59+
if: github.ref != 'refs/heads/master'
60+
uses: docker/build-push-action@v6
61+
with:
62+
file: Dockerfile
63+
push: true
64+
platforms: linux/amd64,linux/arm64
65+
tags: |
66+
ghcr.io/${{ env.IMAGE_NAME }}:nightly-${{ github.sha }}

0 commit comments

Comments
 (0)