@@ -2,20 +2,21 @@ name: Main
22on :
33 push :
44 branches :
5- - ' develop'
6- - ' feature/update**'
7- - ' feature/server_esm**'
5+ - " develop"
6+ - " feature/update**"
7+ - " feature/server_esm**"
88 paths-ignore :
9- - ' docs/**'
10- - ' bin/**'
9+ - " docs/**"
10+ - " bin/**"
1111 workflow_dispatch :
1212
1313concurrency :
1414 group : ${{ github.workflow }}-${{ github.ref }}
1515 cancel-in-progress : true
1616
1717env :
18- REGISTRY : ghcr.io
18+ GHCR_REGISTRY : ghcr.io
19+ DOCKERHUB_REGISTRY : docker.io
1920 IMAGE_NAME : ${{ github.repository }}
2021
2122jobs :
@@ -141,7 +142,7 @@ jobs:
141142 name : TriliumNext Notes for Windows (Setup)
142143 path : out/make/squirrel.windows/x64/*.exe
143144 build_docker :
144- name : Build Docker image
145+ name : Build Docker images
145146 runs-on : ubuntu-latest
146147 permissions :
147148 contents : read
@@ -150,40 +151,68 @@ jobs:
150151 id-token : write
151152 steps :
152153 - uses : actions/checkout@v4
153- - name : Log in to the Container registry
154- uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
154+ - name : Extract metadata (tags, labels) for GHCR image
155+ id : ghcr-meta
156+ uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
155157 with :
156- registry : ${{ env.REGISTRY }}
157- username : ${{ github.actor }}
158- password : ${{ secrets.GITHUB_TOKEN }}
159- - name : Extract metadata (tags, labels) for Docker
160- id : meta
158+ images : ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
159+ - name : Extract metadata (tags, labels) for DockerHub image
160+ id : dh-meta
161161 uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
162162 with :
163- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
163+ images : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
164164 - name : Set up node & dependencies
165165 uses : actions/setup-node@v4
166166 with :
167167 node-version : 20
168168 cache : " npm"
169- - run : npm ci
169+ - run : npm ci
170170 - name : Run the TypeScript build
171171 run : npx tsc
172172 - name : Create server-package.json
173173 run : cat package.json | grep -v electron > server-package.json
174+ - name : Log in to the GHCR container registry
175+ uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
176+ with :
177+ registry : ${{ env.GHCR_REGISTRY }}
178+ username : ${{ github.actor }}
179+ password : ${{ secrets.GITHUB_TOKEN }}
174180 - uses : docker/setup-buildx-action@v3
175- - uses : docker/build-push-action@v6
176- id : push
181+ - name : Build and push container image to GHCR
182+ uses : docker/build-push-action@v6
183+ id : ghcr-push
184+ with :
185+ context : .
186+ push : true
187+ tags : ${{ steps.ghcr-meta.outputs.tags }}
188+ labels : ${{ steps.ghcr-meta.outputs.labels }}
189+ cache-from : type=gha
190+ cache-to : type=gha,mode=max
191+ - name : Generate and push artifact attestation to GHCR
192+ uses : actions/attest-build-provenance@v1
193+ with :
194+ subject-name : ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
195+ subject-digest : ${{ steps.ghcr-push.outputs.digest }}
196+ push-to-registry : true
197+ - name : Log in to the DockerHub container registry
198+ uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
199+ with :
200+ registry : ${{ env.DOCKERHUB_REGISTRY }}
201+ username : ${{ secrets.DOCKERHUB_USERNAME }}
202+ password : ${{ secrets.DOCKERHUB_TOKEN }}
203+ - name : Build and push image to DockerHub
204+ uses : docker/build-push-action@v6
205+ id : dh-push
177206 with :
178207 context : .
179208 push : true
180- tags : ${{ steps.meta.outputs.tags }}
181- labels : ${{ steps.meta.outputs.labels }}
209+ tags : ${{ steps.dh- meta.outputs.tags }}
210+ labels : ${{ steps.dh- meta.outputs.labels }}
182211 cache-from : type=gha
183212 cache-to : type=gha,mode=max
184- - name : Generate artifact attestation
213+ - name : Generate and push artifact attestation to DockerHub
185214 uses : actions/attest-build-provenance@v1
186215 with :
187- subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
188- subject-digest : ${{ steps.push.outputs.digest }}
189- push-to-registry : true
216+ subject-name : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}}
217+ subject-digest : ${{ steps.dh- push.outputs.digest }}
218+ push-to-registry : true
0 commit comments