Skip to content

Commit 2358b91

Browse files
committed
CI/Docker: split in two steps the build & publish
1 parent 2977864 commit 2358b91

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

.github/workflows/docker.yaml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,32 @@ jobs:
3838
3939
- name: Login to Docker Hub
4040
uses: docker/login-action@v3
41+
if: env.SHOULD_PUBLISH == 'true'
4142
with:
4243
username: ${{ secrets.DOCKERHUB_USERNAME }}
4344
password: ${{ secrets.DOCKERHUB_PASSWORD }}
4445

4546
- name: Set up Docker Buildx
4647
uses: docker/setup-buildx-action@v3
4748

48-
- name: Build and push by digest
49+
- name: Build Docker image
4950
id: build
5051
uses: docker/build-push-action@v6
5152
with:
5253
context: .
5354
platforms: ${{ matrix.arch.platform }}
5455
cache-from: type=gha
5556
cache-to: type=gha,mode=max
56-
# :warning:
57-
# Push only if:
58-
# - main
59-
# - develop
60-
# - a tag
61-
outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') }}
57+
outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=false
58+
59+
- name: Push Docker image by digest
60+
if: env.SHOULD_PUBLISH == 'true'
61+
uses: docker/build-push-action@v6
62+
with:
63+
context: .
64+
platforms: ${{ matrix.arch.platform }}
65+
cache-from: type=gha
66+
outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=true
6267

6368
- name: Export digest
6469
run: |
@@ -76,12 +81,7 @@ jobs:
7681

7782
merge-openmina-node-image:
7883
runs-on: ubuntu-latest
79-
# :warning:
80-
# Only if:
81-
# - main
82-
# - develop
83-
# - a tag
84-
if: github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/')
84+
if: env.SHOULD_PUBLISH == 'true'
8585
needs:
8686
- build-openmina-node-image
8787
steps:
@@ -148,14 +148,15 @@ jobs:
148148

149149
- name: Login to Docker Hub
150150
uses: docker/login-action@v3
151+
if: env.SHOULD_PUBLISH == 'true'
151152
with:
152153
username: ${{ secrets.DOCKERHUB_USERNAME }}
153154
password: ${{ secrets.DOCKERHUB_PASSWORD }}
154155

155156
- name: Set up Docker Buildx
156157
uses: docker/setup-buildx-action@v3
157158

158-
- name: Build and push by digest
159+
- name: Build Docker image
159160
id: build
160161
uses: docker/build-push-action@v6
161162
with:
@@ -165,11 +166,18 @@ jobs:
165166
BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }}
166167
cache-from: type=gha
167168
cache-to: type=gha,mode=max
168-
# Only if:
169-
# - main
170-
# - develop
171-
# - a tag
172-
outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/') }}
169+
outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=false
170+
171+
- name: Push Docker image by digest
172+
if: env.SHOULD_PUBLISH == 'true'
173+
uses: docker/build-push-action@v6
174+
with:
175+
context: ./frontend
176+
platforms: ${{ matrix.arch.platform }}
177+
build-args: |
178+
BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }}
179+
cache-from: type=gha
180+
outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=true
173181

174182
- name: Export digest
175183
run: |
@@ -191,7 +199,7 @@ jobs:
191199
configuration:
192200
- build_configuration: production
193201
runs-on: ubuntu-latest
194-
if: github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/')
202+
if: env.SHOULD_PUBLISH == 'true'
195203
needs:
196204
- build-openmina-frontend-image
197205
steps:

0 commit comments

Comments
 (0)