@@ -17,21 +17,31 @@ jobs:
1717 permissions :
1818 contents : read
1919 packages : write
20+
2021 steps :
22+ - name : Checkout
23+ uses : actions/checkout@v4
24+
2125 - name : Login to GitHub Container Registry
2226 uses : docker/login-action@v3
2327 with :
2428 registry : ghcr.io
2529 username : ${{ github.repository_owner }}
2630 password : ${{ secrets.GITHUB_TOKEN }}
2731
32+ - name : Login to Docker Hub
33+ uses : docker/login-action@v3
34+ with :
35+ username : ${{ secrets.DOCKERHUB_USERNAME }}
36+ password : ${{ secrets.DOCKERHUB_TOKEN }}
37+
2838 - name : Set up QEMU
2939 uses : docker/setup-qemu-action@v3
3040
3141 - name : Set up Docker Buildx
3242 uses : docker/setup-buildx-action@v3
33-
34- - name : Docker meta
43+
44+ - name : Docker meta (GHCR only)
3545 id : meta
3646 uses : docker/metadata-action@v5
3747 with :
@@ -41,11 +51,27 @@ jobs:
4151 type=ref,event=pr
4252 type=semver,pattern={{version}}
4353 type=semver,pattern={{major}}.{{minor}}
44-
54+
55+ - name : Determine Docker Hub Tag
56+ id : hubtag
57+ run : |
58+ if [[ "${GITHUB_REF_NAME}" == "main" ]]; then
59+ echo "tag=latest" >> $GITHUB_OUTPUT
60+ else
61+ echo "tag=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
62+ fi
63+ echo "dockerhub_image=${{ secrets.DOCKERHUB_USERNAME }}/soularr" >> $GITHUB_OUTPUT
64+
4565 - name : Build and push
4666 uses : docker/build-push-action@v6
4767 with :
4868 platforms : linux/amd64,linux/arm64
4969 push : ${{ github.event_name != 'pull_request' }}
50- tags : ${{ steps.meta.outputs.tags }}
70+ tags : |
71+ # GHCR tags from metadata-action
72+ ${{ steps.meta.outputs.tags }}
73+
74+ # Docker Hub tag (branch or latest)
75+ ${{ steps.hubtag.outputs.dockerhub_image }}:${{ steps.hubtag.outputs.tag }}
76+
5177 labels : ${{ steps.meta.outputs.labels }}
0 commit comments