11name : Create docker images
22
3- on : [create]
3+ on :
4+ create :
5+ workflow_dispatch :
6+ inputs :
7+ tag :
8+ description : ' Tag to build (e.g., v2.10.0, 2.10.0, v2.10, v2)'
9+ required : true
10+ type : string
411
512jobs :
613 build :
714 name : Build, push, and deploy
8- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
15+ if : ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }}
916 runs-on : ubuntu-latest
1017
1118 strategy :
1421
1522 steps :
1623 - uses : actions/checkout@v3
24+ with :
25+ ref : ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
1726
1827 - name : Set env
1928 run : |
@@ -22,15 +31,41 @@ jobs:
2231 - name : Generate tags
2332 id : generate_tags
2433 run : |
25- echo "tag_patch=$(echo ${{ matrix.db-type }})-${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
26- echo "tag_minor=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1,2)" >> $GITHUB_ENV
27- echo "tag_major=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1)" >> $GITHUB_ENV
34+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
35+ TAG=${{ inputs.tag }}
36+ else
37+ TAG=${GITHUB_REF#refs/tags/}
38+ fi
39+
40+ # Remove 'v' prefix if present
41+ VERSION=${TAG#v}
42+
43+ # Split version into parts
44+ IFS='.' read -ra PARTS <<< "$VERSION"
45+
46+ # Generate tags based on number of version parts
47+ if [ ${#PARTS[@]} -eq 1 ]; then
48+ # Only major version (e.g., v2 or 2)
49+ echo "tag_major=$(echo ${{ matrix.db-type }})-${PARTS[0]}" >> $GITHUB_ENV
50+ echo "TAGS=${{ matrix.db-type }}-${PARTS[0]}" >> $GITHUB_ENV
51+ elif [ ${#PARTS[@]} -eq 2 ]; then
52+ # Major.minor version (e.g., v2.10 or 2.10)
53+ echo "tag_major=$(echo ${{ matrix.db-type }})-${PARTS[0]}" >> $GITHUB_ENV
54+ echo "tag_minor=$(echo ${{ matrix.db-type }})-${PARTS[0]}.${PARTS[1]}" >> $GITHUB_ENV
55+ echo "TAGS=${{ matrix.db-type }}-${PARTS[0]}, ${{ matrix.db-type }}-${PARTS[0]}.${PARTS[1]}" >> $GITHUB_ENV
56+ else
57+ # Full version (e.g., v2.10.0 or 2.10.0)
58+ echo "tag_major=$(echo ${{ matrix.db-type }})-${PARTS[0]}" >> $GITHUB_ENV
59+ echo "tag_minor=$(echo ${{ matrix.db-type }})-${PARTS[0]}.${PARTS[1]}" >> $GITHUB_ENV
60+ echo "tag_patch=$(echo ${{ matrix.db-type }})-${VERSION}" >> $GITHUB_ENV
61+ echo "TAGS=${{ matrix.db-type }}-${PARTS[0]}, ${{ matrix.db-type }}-${PARTS[0]}.${PARTS[1]}, ${{ matrix.db-type }}-${VERSION}" >> $GITHUB_ENV
62+ fi
2863
2964 - uses : mr-smithers-excellent/docker-build-push@v6
3065 name : Build & push Docker image to ghcr.io for ${{ matrix.db-type }}
3166 with :
3267 image : umami
33- tags : ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}
68+ tags : ${{ env.TAGS }}
3469 buildArgs : DATABASE_TYPE=${{ matrix.db-type }}
3570 registry : ghcr.io
3671 multiPlatform : true
4277 name : Build & push Docker image to docker.io for ${{ matrix.db-type }}
4378 with :
4479 image : umamisoftware/umami
45- tags : ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}
80+ tags : ${{ env.TAGS }}
4681 buildArgs : DATABASE_TYPE=${{ matrix.db-type }}
4782 registry : docker.io
4883 username : ${{ secrets.DOCKER_USERNAME }}
49- password : ${{ secrets.DOCKER_PASSWORD }}
84+ password : ${{ secrets.DOCKER_PASSWORD }}
0 commit comments