@@ -3,6 +3,12 @@ name: Build and Push Docker Images
33on :
44 push :
55 branches : [deploy]
6+ workflow_dispatch :
7+ inputs :
8+ version :
9+ description : " Version tag (leave empty to use package.json version and tag as latest)"
10+ required : false
11+ type : string
612
713jobs :
814 build-and-push :
@@ -13,40 +19,63 @@ jobs:
1319
1420 steps :
1521 - name : Checkout repository
16- uses : actions/checkout@v3
22+ uses : actions/checkout@v4
23+
24+ - name : Set up QEMU
25+ uses : docker/setup-qemu-action@v3
26+ with :
27+ platforms : arm64
1728
1829 - name : Set up Docker Buildx
19- uses : docker/setup-buildx-action@v2
30+ uses : docker/setup-buildx-action@v3
2031
21- # Login to Docker Hub
2232 - name : Log in to Docker Hub
23- uses : docker/login-action@v2
33+ uses : docker/login-action@v3
2434 with :
2535 registry : docker.io
2636 username : ${{ secrets.DOCKERHUB_USERNAME }}
2737 password : ${{ secrets.DOCKERHUB_TOKEN }}
2838
29- # Login to GitHub Container Registry
3039 - name : Log in to GitHub Container Registry
31- uses : docker/login-action@v2
40+ uses : docker/login-action@v3
3241 with :
3342 registry : ghcr.io
3443 username : ${{ github.actor }}
3544 password : ${{ secrets.GHCR_TOKEN }}
3645
37- - name : Extract version from package.json
46+ - name : Determine version and tags
3847 id : vars
3948 run : |
40- VERSION=$(node -p "require('./package.json').version")
49+ if [ -n "${{ inputs.version }}" ]; then
50+ VERSION="${{ inputs.version }}"
51+ USE_LATEST="false"
52+ else
53+ VERSION=$(node -p "require('./package.json').version")
54+ USE_LATEST="true"
55+ fi
56+
57+ TAGS="docker.io/tbosk/mkfd:${VERSION}"$'\n'"ghcr.io/tbosak/mkfd:${VERSION}"
58+ if [ "${USE_LATEST}" = "true" ]; then
59+ TAGS="$TAGS"$'\n'"docker.io/tbosk/mkfd:latest"$'\n'"ghcr.io/tbosak/mkfd:latest"
60+ fi
61+
4162 echo "VERSION=$VERSION" >> $GITHUB_ENV
63+ echo "USE_LATEST=$USE_LATEST" >> $GITHUB_ENV
64+ echo "TAGS<<EOF" >> $GITHUB_ENV
65+ echo "$TAGS" >> $GITHUB_ENV
66+ echo "EOF" >> $GITHUB_ENV
67+
68+ echo "Building version: $VERSION (latest tag: $USE_LATEST)"
69+ echo "Docker tags:"
70+ echo "$TAGS"
4271
43- - name : Build and push Docker images to Docker Hub and GHCR
44- uses : docker/build-push-action@v4
72+ - name : Build and push multi-arch images to Docker Hub and GHCR
73+ uses : docker/build-push-action@v6
4574 with :
4675 context : .
4776 push : true
48- tags : |
49- docker.io/tbosk/mkfd:latest
50- docker.io/tbosk/mkfd:${{ env.VERSION }}
51- ghcr.io/tbosak/mkfd:latest
52- ghcr.io/tbosak/mkfd:${{ env.VERSION }}
77+ platforms : linux/amd64,linux/arm64
78+ tags : ${{ env.TAGS }}
79+ provenance : true
80+ network : host
81+ allow : network.host
0 commit comments