1- name : Build and Publish Demo Image
1+ name : Build and Push Docker Image
22
33on :
44 push :
55 tags :
66 - ' *'
77
8- workflow_dispatch : ~
8+ workflow_dispatch :
9+ inputs :
10+ version :
11+ description : ' Tag version (e.g. 2.0.0)'
12+ required : true
913
1014jobs :
1115 build :
2125 uses : actions/checkout@v3
2226
2327 - name : Set up Docker Buildx
24- uses : docker/setup-buildx-action@v2
28+ uses : docker/setup-buildx-action@v3
2529
2630 - name : Log in to GitHub Container Registry
2731 uses : docker/login-action@v3
@@ -30,28 +34,35 @@ jobs:
3034 username : ${{ github.actor }}
3135 password : ${{ secrets.GITHUB_TOKEN }}
3236
33- - name : Extract version info
34- id : version
37+ - name : Normalize repository name (lowercase)
38+ run : |
39+ echo "REPO_LOWER=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
40+
41+ - name : Set custom tag for manual run
3542 run : |
3643 if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
37- git fetch --tags
38- TAG_NAME=$(git describe --tags "$(git rev-list --tags --max-count=1)")
44+ echo "CUSTOM_TAG=type=raw,value=${{ github.event.inputs.version }}" >> $GITHUB_ENV
3945 else
40- TAG_NAME="${GITHUB_REF#refs/tags/}"
46+ echo "CUSTOM_TAG=" >> $GITHUB_ENV
4147 fi
42-
43- MAJOR_MINOR=$(echo "$TAG_NAME" | cut -d. -f1,2)
44-
45- echo "Using tag: $TAG_NAME"
46- echo "TAG=$TAG_NAME" >> $GITHUB_ENV
47- echo "MAJOR_MINOR=$MAJOR_MINOR" >> $GITHUB_ENV
48+
49+ - name : Docker meta
50+ id : meta
51+ uses : docker/metadata-action@v5
52+ with :
53+ images : |
54+ ghcr.io/${{ env.REPO_LOWER }}
55+ tags : |
56+ ${{ env.CUSTOM_TAG }}
57+ type=semver,pattern={{version}}
58+ type=semver,pattern={{major}}.{{minor}}
59+ flavor : |
60+ latest=false
4861
4962 - name : Build and push Docker image
50- uses : docker/build-push-action@v2
63+ uses : docker/build-push-action@v6
5164 with :
5265 context : .
66+ file : .docker/Dockerfile
5367 push : true
54- tags : |
55- ghcr.io/${{ github.repository_owner }}/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]'):${{ env.TAG }}
56- ghcr.io/${{ github.repository_owner }}/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]'):${{ env.MAJOR_MINOR }}
57-
68+ tags : ${{ steps.meta.outputs.tags }}
0 commit comments