Skip to content

Commit cf01144

Browse files
committed
fix(): try to push new am64 image
fix(): try to push new am64 image fix(): try to push new am64 image fix(): separate docker web build fix(): separate docker web build fix(): use github example for matrix build fix(): use github example for matrix build fix(): use github example for matrix build fix(): use github example for matrix build fix(): use github example for matrix build
1 parent fe16230 commit cf01144

File tree

1 file changed

+126
-14
lines changed

1 file changed

+126
-14
lines changed

.github/workflows/build-self-host-docker-images.yml

Lines changed: 126 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
name: Build Self-Hosting Docker Images
2+
3+
env:
4+
WEB_IMAGE: ghcr.io/omnivore-app/sh-web
5+
26
on:
37
push:
48
branches:
@@ -95,23 +99,131 @@ jobs:
9599
file: packages/local-mail-watcher/Dockerfile
96100
cache-from: type=registry,ref=ghcr.io/omnivore-app/sh-local-mail-watcher:cache
97101
cache-to: type=registry,ref=ghcr.io/omnivore-app/sh-local-mail-watcher:cache,mode=max
102+
build-selfhost-web-images:
103+
name: Build self-host web images
104+
permissions:
105+
contents: read
106+
packages: write
107+
attestations: write
108+
id-token: write
109+
strategy:
110+
matrix:
111+
platform:
112+
- linux/amd64
113+
- linux/arm64
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Prepare
117+
run: |
118+
platform=${{ matrix.platform }}
119+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
98120
99-
- name: Build and push web (x86)
100-
uses: docker/build-push-action@v6
121+
- name: Checkout
122+
uses: actions/checkout@v4
101123
with:
102-
platforms: linux/amd64
103-
push: true
104-
tags: ghcr.io/omnivore-app/sh-web:latest
105-
file: packages/web/Dockerfile-self
106-
cache-from: type=registry,ref=ghcr.io/omnivore-app/sh-web:cache
107-
cache-to: type=registry,ref=ghcr.io/omnivore-app/sh-web:cache,mode=max
124+
fetch-depth: 0
125+
126+
- name: 'Login to GitHub container registry'
127+
uses: docker/login-action@v3
128+
with:
129+
registry: ghcr.io
130+
username: ${{github.actor}}
131+
password: ${{secrets.GITHUB_TOKEN}}
132+
133+
- name: Set up QEMU
134+
uses: docker/setup-qemu-action@v3
108135

109-
- name: Build and push web (arm64)
136+
- name: Set up Docker Buildx
137+
uses: docker/setup-buildx-action@v3
138+
139+
- name: Docker meta
140+
id: meta
141+
uses: docker/metadata-action@v5
142+
with:
143+
images: ${{ env.WEB_IMAGE }}
144+
145+
- name: Build and push Web with Digest
146+
id: build
110147
uses: docker/build-push-action@v6
111148
with:
112-
platforms: linux/arm64
113-
push: true
114-
tags: ghcr.io/omnivore-app/sh-web:latest
115149
file: packages/web/Dockerfile-self
116-
cache-from: type=registry,ref=ghcr.io/omnivore-app/sh-web-arm:cache
117-
cache-to: type=registry,ref=ghcr.io/omnivore-app/sh-web-arm:cache,mode=max
150+
platforms: ${{ matrix.platform }}
151+
labels: ${{ steps.meta.outputs.labels }}
152+
tags: ${{ env.WEB_IMAGE }}
153+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
154+
cache-from: type=registry,ref=ghcr.io/omnivore-app/sh-web-${{matrix.platform}}:cache
155+
cache-to: type=registry,ref=ghcr.io/omnivore-app/sh-web-${{matrix.platform}}:cache,mode=max
156+
- name: Export digest
157+
run: |
158+
mkdir -p ${{ runner.temp }}/digests
159+
digest="${{ steps.build.outputs.digest }}"
160+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
161+
162+
- name: Upload digest
163+
uses: actions/upload-artifact@v4
164+
with:
165+
name: digests-${{ env.PLATFORM_PAIR }}
166+
path: ${{ runner.temp }}/digests/*
167+
if-no-files-found: error
168+
retention-days: 1
169+
merge:
170+
runs-on: ubuntu-latest
171+
needs:
172+
- build-selfhost-web-images
173+
steps:
174+
- name: Download digests
175+
uses: actions/download-artifact@v4
176+
with:
177+
path: ${{ runner.temp }}/digests
178+
pattern: digests-*
179+
merge-multiple: true
180+
181+
- name: 'Login to GitHub container registry'
182+
uses: docker/login-action@v3
183+
with:
184+
registry: ghcr.io
185+
username: ${{github.actor}}
186+
password: ${{secrets.GITHUB_TOKEN}}
187+
188+
- name: Set up Docker Buildx
189+
uses: docker/setup-buildx-action@v3
190+
191+
- name: Docker meta
192+
id: meta
193+
uses: docker/metadata-action@v5
194+
with:
195+
images: ${{ env.WEB_IMAGE }}
196+
tags: |
197+
type=ref,event=branch
198+
type=ref,event=pr
199+
type=raw,value=latest
200+
201+
- name: Create manifest list and push
202+
working-directory: ${{ runner.temp }}/digests
203+
run: |
204+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
205+
$(printf '${{ env.WEB_IMAGE }}@sha256:%s ' *)
206+
207+
- name: Inspect image
208+
run: |
209+
docker buildx imagetools inspect ${{ env.WEB_IMAGE }}:${{ steps.meta.outputs.version }}
210+
#
211+
# - name: Build and push web (x86)
212+
# uses: docker/build-push-action@v6
213+
# with:
214+
# platforms: linux/amd64
215+
# push: true
216+
# tags: ghcr.io/omnivore-app/sh-web:latest
217+
# file: packages/web/Dockerfile-self
218+
# cache-from: type=registry,ref=ghcr.io/omnivore-app/sh-web:cache
219+
# cache-to: type=registry,ref=ghcr.io/omnivore-app/sh-web:cache,mode=max
220+
#
221+
# - name: Build and push web (arm64)
222+
# uses: docker/build-push-action@v6
223+
# with:
224+
# platforms: linux/arm64
225+
# push: true
226+
# tags: ghcr.io/omnivore-app/sh-web:latest
227+
# file: packages/web/Dockerfile-self
228+
# cache-from: type=registry,ref=ghcr.io/omnivore-app/sh-web-arm:cache
229+
# cache-to: type=registry,ref=ghcr.io/omnivore-app/sh-web-arm:cache,mode=max

0 commit comments

Comments
 (0)