@@ -96,93 +96,89 @@ jobs:
9696 with :
9797 name : pigallery2-release
9898 path : release
99- build-dockerx :
100- runs-on : [ ubuntu-latest ]
101- needs : [ test, create-release ]
99+
100+ # --- MULTI-PLATFORM DOCKER VERIFICATION ---
101+ build-verify-docker :
102+ runs-on : ubuntu-latest
103+ needs : [test, create-release]
102104 strategy :
105+ fail-fast : false # Ensures one platform failure doesn't stop others from testing
103106 matrix :
104- container : [alpine, debian-trixie ]
107+ container : [alpine, debian-trixie]
105108 include :
106109 - container : alpine
107- platforms : linux/amd64,linux/arm64, linux/arm/v7
110+ platforms : linux/amd64,linux/arm64,linux/arm/v7
108111 - container : debian-trixie
109112 platforms : linux/amd64,linux/arm64
110-
111113 steps :
112114 - name : Checkout
113115 uses : actions/checkout@v4
114- - uses : actions/download-artifact@v4
116+ - name : Download Release Artifact
117+ uses : actions/download-artifact@v4
115118 with :
116119 name : pigallery2-release
117120 path : pigallery2-release
121+
118122 - name : Set up QEMU
119123 uses : docker/setup-qemu-action@v3
120124 - name : Set up Docker Buildx
121125 uses : docker/setup-buildx-action@v3
122- - name : Login to DockerHub
123- uses : docker/login-action@v3
124- with :
125- username : ${{ secrets.REGISTRY_USERNAME }}
126- password : ${{ secrets.REGISTRY_PASSWORD }}
127- - name : Build docker
128- uses : docker/build-push-action@v5
129- with :
130- context : .
131- file : docker/${{ matrix.container }}/Dockerfile.build
132- platforms : ${{ matrix.platforms }}
133- - name : Push experimental
134- if : ${{ github.ref == 'refs/heads/experimental' }}
135- uses : docker/build-push-action@v5
136- with :
137- context : .
138- file : docker/${{ matrix.container }}/Dockerfile.build
139- platforms : ${{ matrix.platforms }}
140- push : true
141- tags : ${{ secrets.REGISTRY_NAMESPACE }}/pigallery2:experimental-${{ matrix.container }}
142- - name : Push secondary edge builds on new master commit
143- # github.ref: branches the format is refs/heads/<branch_name> PRs and Tags are different
144- if : ${{github.ref == 'refs/heads/master' && matrix.container != 'debian-trixie'}}
126+
127+ - name : Build and Verify Platforms
145128 uses : docker/build-push-action@v5
146129 with :
147130 context : .
148131 file : docker/${{ matrix.container }}/Dockerfile.build
149132 platforms : ${{ matrix.platforms }}
150- push : true
151- tags : ${{ secrets.REGISTRY_NAMESPACE }}/pigallery2:edge-${{ matrix.container }}
152- - name : Push main edge build on new master commit
153- if : ${{github.ref == 'refs/heads/master' && matrix.container == 'debian-trixie'}}
154- uses : docker/build-push-action@v5
133+ push : false # Do not push yet
134+ cache-from : type=gha
135+ cache-to : type=gha,mode=max
136+
137+ # --- DOCKER LOGIN AND PUSH ---
138+ push-docker :
139+ runs-on : ubuntu-latest
140+ needs : [build-verify-docker]
141+ # Only push on branch merges or tags, never on plain PRs
142+ if : github.event_name != 'pull_request'
143+ strategy :
144+ matrix :
145+ container : [alpine, debian-trixie]
146+ include :
147+ - container : alpine
148+ platforms : linux/amd64,linux/arm64,linux/arm/v7
149+ - container : debian-trixie
150+ platforms : linux/amd64,linux/arm64
151+ steps :
152+ - name : Checkout
153+ uses : actions/checkout@v4
154+ - name : Download Release Artifact
155+ uses : actions/download-artifact@v4
155156 with :
156- context : .
157- file : docker/${{ matrix.container }}/Dockerfile.build
158- platforms : ${{ matrix.platforms }}
159- push : true
160- tags : |
161- ${{ secrets.REGISTRY_NAMESPACE }}/pigallery2:edge
162- ${{ secrets.REGISTRY_NAMESPACE }}/pigallery2:edge-${{ matrix.container }}
163- - name : Push release on new Tag
164- if : ${{ startsWith(github.ref_type , 'tag') && !github.event.issue.pull_request && matrix.container != 'debian-trixie'}}
165- uses : docker/build-push- action@v5
157+ name : pigallery2-release
158+ path : pigallery2-release
159+
160+ - name : Set up QEMU
161+ uses : docker/setup-qemu-action@v3
162+ - name : Set up Docker Buildx
163+ uses : docker/setup-buildx-action@v3
164+
165+ - name : Login to DockerHub
166+ uses : docker/login- action@v3
166167 with :
167- context : .
168- file : docker/${{ matrix.container }}/Dockerfile.build
169- platforms : ${{ matrix.platforms }}
170- push : true
171- tags : |
172- ${{ secrets.REGISTRY_NAMESPACE }}/pigallery2:edge-${{ matrix.container }}
173- ${{ secrets.REGISTRY_NAMESPACE }}/pigallery2:${{ github.ref_name }}-${{ matrix.container }}
174- ${{ secrets.REGISTRY_NAMESPACE }}/pigallery2:latest-${{ matrix.container }}
175- - name : Push latest on new Tag
176- if : ${{ startsWith(github.ref_type, 'tag') && !github.event.issue.pull_request && matrix.container == 'debian-trixie'}}
168+ username : ${{ secrets.REGISTRY_USERNAME }}
169+ password : ${{ secrets.REGISTRY_PASSWORD }}
170+
171+ - name : Push Verified Images
177172 uses : docker/build-push-action@v5
178173 with :
179174 context : .
180175 file : docker/${{ matrix.container }}/Dockerfile.build
181176 platforms : ${{ matrix.platforms }}
182177 push : true
178+ cache-from : type=gha # Pulls from the cache created in Job 1
183179 tags : |
184- ${{ secrets.REGISTRY_NAMESPACE } }/pigallery2:edge-${{ matrix.container }}
185- ${{ secrets.REGISTRY_NAMESPACE }}/pigallery2:${{ github.ref_name }}-${{ matrix.container }}
186- ${{ secrets.REGISTRY_NAMESPACE }} /pigallery2:latest-${{ matrix.container }}
187- ${{ secrets.REGISTRY_NAMESPACE }} /pigallery2:${{ github.ref_name }}
188- ${{ secrets.REGISTRY_NAMESPACE }} /pigallery2:latest
180+ ${{ (github.ref == 'refs/heads/master' && matrix.container == 'debian-trixie') && format('{0}/pigallery2:edge,{0 }/pigallery2:edge-{1}', secrets.REGISTRY_NAMESPACE, matrix.container) || '' }}
181+ ${{ (github.ref == 'refs/heads/master' && matrix.container != 'debian-trixie') && format('{0}/pigallery2:edge-{1}', secrets.REGISTRY_NAMESPACE, matrix.container) || '' }}
182+ ${{ (github.ref == 'refs/heads/experimental') && format('{0} /pigallery2:experimental-{1}', secrets.REGISTRY_NAMESPACE, matrix.container) || '' }}
183+ ${{ (startsWith(github.ref, 'refs/tags/') && matrix.container == 'debian-trixie') && format('{0}/pigallery2:{1},{0} /pigallery2:latest,{0}/pigallery2:edge-{2}', secrets.REGISTRY_NAMESPACE, github.ref_name, matrix.container) || '' }}
184+ ${{ (startsWith(github.ref, 'refs/tags/') && matrix.container != 'debian-trixie') && format('{0}/pigallery2:{1}-{2},{0} /pigallery2:latest-{2},{0}/pigallery2:edge-{2}', secrets.REGISTRY_NAMESPACE, github.ref_name, matrix.container) || '' }}
0 commit comments