11name : branch build & push
22
33on :
4- # schedule:
5- # - cron: '50 15 * * *' #Change this to when you want automatic builds
64 push :
75 paths-ignore :
86 - ' README.md'
@@ -17,75 +15,106 @@ jobs:
1715 build :
1816
1917 runs-on : ubuntu-latest
18+
2019 permissions :
2120 contents : read
2221 packages : write
23- # This is used to complete the identity challenge
24- # with sigstore/fulcio when running outside of PRs.
2522 id-token : write
2623
2724 steps :
2825 - name : Checkout repository
29- uses : actions/checkout@v3
30-
26+ uses : actions/checkout@v4
27+
3128 - name : Set up QEMU
32- uses : docker/setup-qemu-action@v2
33-
29+ uses : docker/setup-qemu-action@v3
30+
3431 - name : Setup Docker buildx
35- uses : docker/setup-buildx-action@v2
32+ uses : docker/setup-buildx-action@v3
3633
3734 - name : Cache Docker layers
38- uses : actions/cache@v3
35+ uses : actions/cache@v4
3936 with :
4037 path : /tmp/.buildx-cache
4138 key : ${{ runner.os }}-buildx-${{ github.sha }}
4239 restore-keys : |
4340 ${{ runner.os }}-buildx-
4441
42+ # ------------------------------------------
43+ # Login to Docker Hub
44+ # ------------------------------------------
4545 - name : Login to Docker Hub
46- uses : docker/login-action@v2
46+ uses : docker/login-action@v3
4747 with :
48+ registry : docker.io
4849 username : ${{ secrets.DOCKERHUB_USERNAME }}
4950 password : ${{ secrets.DOCKERHUB_TOKEN }}
50-
51+
52+ # ------------------------------------------
53+ # Login to GitHub Container Registry (GHCR)
54+ # ------------------------------------------
55+ - name : Login to GHCR
56+ uses : docker/login-action@v3
57+ with :
58+ registry : ghcr.io
59+ username : ${{ github.actor }}
60+ password : ${{ secrets.GITHUB_TOKEN }}
61+
62+ # ------------------------------------------------------
63+ # Build for MAIN → latest (Docker Hub + GHCR)
64+ # ------------------------------------------------------
5165 - name : Production Build and push
5266 if : ${{ github.ref == 'refs/heads/main' }}
53- uses : docker/build-push-action@v3
67+ uses : docker/build-push-action@v5
5468 with :
5569 context : .
5670 push : true
57- tags : ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest
5871 platforms : linux/amd64,linux/arm/v7,linux/arm64/v8
72+ tags : |
73+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest
74+ ghcr.io/${{ github.repository_owner }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest
5975 cache-from : type=local,src=/tmp/.buildx-cache
6076 cache-to : type=local,dest=/tmp/.buildx-cache-new
6177
78+ # ------------------------------------------------------
79+ # Build for TAGS → versioned tags (Docker Hub + GHCR)
80+ # ------------------------------------------------------
6281 - name : Production Get Tag Name
6382 if : startsWith(github.ref, 'refs/tags/v')
6483 uses :
little-core-labs/[email protected] 6584 id : tagName
6685
6786 - name : Production Tag Build and push
6887 if : startsWith(github.ref, 'refs/tags/v')
69- uses : docker/build-push-action@v2
88+ uses : docker/build-push-action@v5
7089 with :
7190 context : .
7291 push : true
73- tags : ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${{ steps.tagName.outputs.tag }}
7492 platforms : linux/amd64,linux/arm/v7,linux/arm64/v8
93+ tags : |
94+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${{ steps.tagName.outputs.tag }}
95+ ghcr.io/${{ github.repository_owner }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${{ steps.tagName.outputs.tag }}
7596 cache-from : type=local,src=/tmp/.buildx-cache
76- cache-to : type=local,dest=/tmp/.buildx-cache-new
97+ cache-to : type=local,dest=/tmp/.buildx-cache-new
7798
99+ # ------------------------------------------------------
100+ # Build for DEVELOP → develop tag (Docker Hub + GHCR)
101+ # ------------------------------------------------------
78102 - name : Development Build and push
79103 if : ${{ github.ref == 'refs/heads/develop' }}
80- uses : docker/build-push-action@v2
104+ uses : docker/build-push-action@v5
81105 with :
82106 context : .
83107 push : true
84- tags : ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:develop
85108 platforms : linux/amd64,linux/arm/v7,linux/arm64/v8
109+ tags : |
110+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:develop
111+ ghcr.io/${{ github.repository_owner }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:develop
86112 cache-from : type=local,src=/tmp/.buildx-cache
87113 cache-to : type=local,dest=/tmp/.buildx-cache-new
88114
115+ # ------------------------------------------
116+ # Move build cache
117+ # ------------------------------------------
89118 - name : Move cache
90119 run : |
91120 rm -rf /tmp/.buildx-cache
0 commit comments