@@ -106,118 +106,100 @@ jobs:
106106 - uses : actions/checkout@v6
107107 with :
108108 persist-credentials : false
109- - name : Determine if images should be published to DockerHub
110- id : dockerhub
111- run : |
112- # check if a release branch, or main, or a tag
113- if [[ "${{ github.ref }}" =~ ^refs/heads/release([0-9]+)$ || "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == refs/tags/* ]]
114- then
115- DOCKERHUB_PUBLISH="1"
116- else
117- DOCKERHUB_PUBLISH="0"
118- fi
119- # debug output
120- echo "dockerhub-publish $DOCKERHUB_PUBLISH"
121- echo "dockerhub-publish=$DOCKERHUB_PUBLISH" >> $GITHUB_OUTPUT
122- - name : Check if push to GHCR is enabled
123- id : check-ghcr
124- env :
125- GHCR_ENABLED : ${{ secrets.GHCR_ENABLED }}
126- run : |
127- echo "Enable push to GHCR: ${{ env.GHCR_ENABLED != '' }}"
128- echo "enable=${{ env.GHCR_ENABLED != '' }}" >> $GITHUB_OUTPUT
129- - name : Check if there is access to repo secrets (needed for build and push)
130- if : steps.dockerhub.outputs.dockerhub-publish == '1' || steps.check-ghcr.outputs.enable == 'true'
131- id : check-build-and-push
132- env :
133- SECRET_ACCESS : ${{ secrets.DOCKERHUB_IMAGE_PREFIX }}
134- run : |
135- echo "Enable build and push: ${{ env.SECRET_ACCESS != '' }}"
136- echo "enable=${{ env.SECRET_ACCESS != '' }}" >> $GITHUB_OUTPUT
137- - name : Get the Docker tag for GHCR
138- id : ghcr-tag
139- if : steps.check-build-and-push.outputs.enable == 'true'
140- uses : docker/metadata-action@v5
141- with :
142- images : |
143- ghcr.io/${{ github.repository }}-server-core
144- tags : |
145- type=schedule
146- type=ref,event=branch
147- type=ref,event=tag
148- type=raw,value=latest,enable={{is_default_branch}}
149- - name : Get the Docker tag for DockerHub
150- id : dockerhub-tag
151- if : steps.check-build-and-push.outputs.enable == 'true'
152- uses : docker/metadata-action@v5
153- with :
154- images : |
155- ${{ secrets.DOCKERHUB_IMAGE_PREFIX }}server-core
156- tags : |
157- type=schedule
158- type=ref,event=branch
159- type=ref,event=tag
160- type=raw,value=latest,enable={{is_default_branch}}
161109 - name : Use Node.js
162- if : steps.check-build-and-push.outputs.enable == 'true'
163110 uses : actions/setup-node@v6
164111 with :
165112 node-version-file : " .node-version"
166113 - uses : ./.github/actions/setup-meteor
167- if : steps.check-build-and-push.outputs.enable == 'true'
168114 - name : restore node_modules
169115 uses : actions/cache@v4
170- if : steps.check-build-and-push.outputs.enable == 'true'
171116 with :
172117 path : |
173118 node_modules
174119 meteor/node_modules
175120 packages/node_modules
176121 key : ${{ runner.os }}-${{ hashFiles('yarn.lock', 'meteor/yarn.lock', 'meteor/.meteor/release', 'packages/yarn.lock') }}
177122 - name : Prepare Environment
178- if : steps.check-build-and-push.outputs.enable == 'true'
179123 run : |
180124 corepack enable
181125
182126 yarn install
183-
184- # setup zodern:types. No linters are setup, so this simply installs the packages
185- yarn meteor lint
186127 - name : Build libs
187- if : steps.check-build-and-push.outputs.enable == 'true'
188128 run : |
189129 yarn build:packages
190130 - name : Persist Built Version information
191- if : steps.check-build-and-push.outputs.enable == 'true'
192131 run : |
193132 cd meteor
194133 yarn inject-git-hash
195134 - name : Prepare webui for meteor build
196- if : steps.check-build-and-push.outputs.enable == 'true'
197135 run : |
198136 rm -Rf meteor/public
199137 cp -R packages/webui/dist meteor/public
200138 - name : Meteor Build
201- if : steps.check-build-and-push.outputs.enable == 'true'
202139 run : |
203140 cd meteor
204141 NODE_OPTIONS="--max-old-space-size=4096" METEOR_DEBUG_BUILD=1 meteor build --allow-superuser --directory .
205142 mv bundle/programs/web.browser/assets/ bundle/programs/web.browser/app/assets/ || true
206-
207143 - name : Meteor Bundle NPM Build
208- if : steps.check-build-and-push.outputs.enable == 'true'
209144 run : |
210145 cd meteor/bundle/programs/server
211146 meteor npm install
212147 - name : Set up Docker Buildx
213- if : steps.check-build-and-push.outputs.enable == 'true'
214148 uses : docker/setup-buildx-action@v3
215- - name : Login to DockerHub
216- if : steps.check-build-and-push.outputs.enable == 'true' && steps.dockerhub.outputs.dockerhub-publish == '1'
217- uses : docker/login-action@v3
149+
150+ # Check how the image should be built and pushed
151+ - name : Determine if images should be published to DockerHub
152+ id : dockerhub
153+ run : |
154+ # check if a release branch, or main, or a tag
155+ if [[ "${{ github.ref }}" =~ ^refs/heads/release([0-9]+)$ || "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == refs/tags/* ]]
156+ then
157+ DOCKERHUB_PUBLISH="1"
158+ else
159+ DOCKERHUB_PUBLISH="0"
160+ fi
161+ # debug output
162+ echo "dockerhub-publish $DOCKERHUB_PUBLISH"
163+ echo "dockerhub-publish=$DOCKERHUB_PUBLISH" >> $GITHUB_OUTPUT
164+ - name : Check if push to GHCR is enabled
165+ id : check-ghcr
166+ env :
167+ GHCR_ENABLED : ${{ secrets.GHCR_ENABLED }}
168+ run : |
169+ echo "Enable push to GHCR: ${{ env.GHCR_ENABLED != '' }}"
170+ echo "enable=${{ env.GHCR_ENABLED != '' }}" >> $GITHUB_OUTPUT
171+ - name : Check if there is access to repo secrets (needed for build and push)
172+ if : steps.dockerhub.outputs.dockerhub-publish == '1' || steps.check-ghcr.outputs.enable == 'true'
173+ id : check-build-and-push
174+ env :
175+ SECRET_ACCESS : ${{ secrets.DOCKERHUB_IMAGE_PREFIX }}
176+ run : |
177+ echo "Enable build and push: ${{ env.SECRET_ACCESS != '' }}"
178+ echo "enable=${{ env.SECRET_ACCESS != '' }}" >> $GITHUB_OUTPUT
179+
180+ # No-push build if no destination
181+ - name : Build without push
182+ if : steps.check-build-and-push.outputs.enable != 'true'
183+ uses : docker/build-push-action@v6
218184 with :
219- username : ${{ secrets.DOCKERHUB_USERNAME }}
220- password : ${{ secrets.DOCKERHUB_TOKEN }}
185+ context : .
186+ file : ./meteor/Dockerfile.circle
187+ push : false
188+ provenance : false
189+
190+ # GHCR build
191+ - name : Get the Docker tag for GHCR
192+ id : ghcr-tag
193+ if : steps.check-build-and-push.outputs.enable == 'true'
194+ uses : docker/metadata-action@v5
195+ with :
196+ images : |
197+ ghcr.io/${{ github.repository }}-server-core
198+ tags : |
199+ type=schedule
200+ type=ref,event=branch
201+ type=ref,event=tag
202+ type=raw,value=latest,enable={{is_default_branch}}
221203 - name : Login to GitHub Container Registry
222204 if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true'
223205 uses : docker/login-action@v3
@@ -236,6 +218,26 @@ jobs:
236218 labels : ${{ steps.ghcr-tag.outputs.labels }}
237219 tags : " ${{ steps.ghcr-tag.outputs.tags }}"
238220 github-token : ${{ github.token }}
221+
222+ # Dockerhub push
223+ - name : Get the Docker tag for DockerHub
224+ id : dockerhub-tag
225+ if : steps.check-build-and-push.outputs.enable == 'true'
226+ uses : docker/metadata-action@v5
227+ with :
228+ images : |
229+ ${{ secrets.DOCKERHUB_IMAGE_PREFIX }}server-core
230+ tags : |
231+ type=schedule
232+ type=ref,event=branch
233+ type=ref,event=tag
234+ type=raw,value=latest,enable={{is_default_branch}}
235+ - name : Login to DockerHub
236+ if : steps.check-build-and-push.outputs.enable == 'true' && steps.dockerhub.outputs.dockerhub-publish == '1'
237+ uses : docker/login-action@v3
238+ with :
239+ username : ${{ secrets.DOCKERHUB_USERNAME }}
240+ password : ${{ secrets.DOCKERHUB_TOKEN }}
239241 - name : Build and push to DockerHub
240242 if : steps.check-build-and-push.outputs.enable == 'true' && steps.dockerhub.outputs.dockerhub-publish == '1'
241243 uses : docker/build-push-action@v6
@@ -246,6 +248,8 @@ jobs:
246248 provenance : false
247249 labels : ${{ steps.dockerhub-tag.outputs.labels }}
248250 tags : ${{ steps.dockerhub-tag.outputs.tags }}
251+
252+ # Trivy scanning
249253 - name : Get image for Trivy scanning
250254 id : trivy-image
251255 if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true' && steps.ghcr-tag.outputs.tags != 0
@@ -289,6 +293,30 @@ jobs:
289293 - uses : actions/checkout@v6
290294 with :
291295 persist-credentials : false
296+
297+ - name : Use Node.js
298+ uses : actions/setup-node@v6
299+ with :
300+ node-version-file : " .node-version"
301+ - name : restore node_modules
302+ uses : actions/cache@v4
303+ with :
304+ path : |
305+ packages/node_modules
306+ key : ${{ runner.os }}-${{ hashFiles('packages/yarn.lock') }}
307+ - name : Build
308+ run : |
309+ corepack enable
310+
311+ cd packages
312+ yarn install
313+ yarn build:single ${{ matrix.gateway-name }}/tsconfig.build.json
314+ yarn run pinst --disable
315+ yarn workspaces focus ${{ matrix.gateway-name }} --production
316+ - name : Set up Docker Buildx
317+ uses : docker/setup-buildx-action@v3
318+
319+ # Check how the image should be built and pushed
292320 - name : Determine if images should be published to DockerHub
293321 id : dockerhub
294322 run : |
@@ -317,6 +345,18 @@ jobs:
317345 run : |
318346 echo "Enable build and push: ${{ env.SECRET_ACCESS != '' }}"
319347 echo "enable=${{ env.SECRET_ACCESS != '' }}" >> $GITHUB_OUTPUT
348+
349+ # No-push build if no destination
350+ - name : Build without push
351+ if : steps.check-build-and-push.outputs.enable != 'true'
352+ uses : docker/build-push-action@v6
353+ with :
354+ context : ./packages
355+ file : ./packages/${{ matrix.gateway-name }}/Dockerfile.circle
356+ push : false
357+ provenance : false
358+
359+ # GHCR build
320360 - name : Get the Docker tag for GHCR
321361 id : ghcr-tag
322362 if : steps.check-build-and-push.outputs.enable == 'true'
@@ -329,6 +369,25 @@ jobs:
329369 type=ref,event=branch
330370 type=ref,event=tag
331371 type=raw,value=latest,enable={{is_default_branch}}
372+ - name : Login to GitHub Container Registry
373+ if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true'
374+ uses : docker/login-action@v3
375+ with :
376+ registry : ghcr.io
377+ username : ${{ github.repository_owner }}
378+ password : ${{ secrets.GITHUB_TOKEN }}
379+ - name : Build and push to GHCR
380+ if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true' && steps.ghcr-tag.outputs.tags != 0
381+ uses : docker/build-push-action@v6
382+ with :
383+ context : ./packages
384+ file : ./packages/${{ matrix.gateway-name }}/Dockerfile.circle
385+ push : true
386+ provenance : false
387+ labels : ${{ steps.ghcr-tag.outputs.labels }}
388+ tags : " ${{ steps.ghcr-tag.outputs.tags }}"
389+
390+ # Dockerhub push
332391 - name : Get the Docker tag for DockerHub
333392 id : dockerhub-tag
334393 if : steps.check-build-and-push.outputs.enable == 'true'
@@ -341,54 +400,12 @@ jobs:
341400 type=ref,event=branch
342401 type=ref,event=tag
343402 type=raw,value=latest,enable={{is_default_branch}}
344- - name : Use Node.js
345- uses : actions/setup-node@v6
346- if : steps.check-build-and-push.outputs.enable == 'true'
347- with :
348- node-version-file : " .node-version"
349- - name : restore node_modules
350- if : steps.check-build-and-push.outputs.enable == 'true'
351- uses : actions/cache@v4
352- with :
353- path : |
354- packages/node_modules
355- key : ${{ runner.os }}-${{ hashFiles('packages/yarn.lock') }}
356- - name : Build
357- if : steps.check-build-and-push.outputs.enable == 'true'
358- run : |
359- corepack enable
360-
361- cd packages
362- yarn install
363- yarn build:single ${{ matrix.gateway-name }}/tsconfig.build.json
364- yarn run pinst --disable
365- yarn workspaces focus ${{ matrix.gateway-name }} --production
366- - name : Set up Docker Buildx
367- if : steps.check-build-and-push.outputs.enable == 'true'
368- uses : docker/setup-buildx-action@v3
369403 - name : Login to DockerHub
370404 if : steps.check-build-and-push.outputs.enable == 'true' && steps.dockerhub.outputs.dockerhub-publish == '1'
371405 uses : docker/login-action@v3
372406 with :
373407 username : ${{ secrets.DOCKERHUB_USERNAME }}
374408 password : ${{ secrets.DOCKERHUB_TOKEN }}
375- - name : Login to GitHub Container Registry
376- if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true'
377- uses : docker/login-action@v3
378- with :
379- registry : ghcr.io
380- username : ${{ github.repository_owner }}
381- password : ${{ secrets.GITHUB_TOKEN }}
382- - name : Build and push to GHCR
383- if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true' && steps.ghcr-tag.outputs.tags != 0
384- uses : docker/build-push-action@v6
385- with :
386- context : ./packages
387- file : ./packages/${{ matrix.gateway-name }}/Dockerfile.circle
388- push : true
389- provenance : false
390- labels : ${{ steps.ghcr-tag.outputs.labels }}
391- tags : " ${{ steps.ghcr-tag.outputs.tags }}"
392409 - name : Build and push to DockerHub
393410 if : steps.check-build-and-push.outputs.enable == 'true' && steps.dockerhub.outputs.dockerhub-publish == '1'
394411 uses : docker/build-push-action@v6
@@ -399,6 +416,8 @@ jobs:
399416 provenance : false
400417 labels : ${{ steps.dockerhub-tag.outputs.labels }}
401418 tags : " ${{ steps.dockerhub-tag.outputs.tags }}"
419+
420+ # Trivy scanning
402421 - name : Get image for Trivy scanning
403422 id : trivy-image
404423 if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true' && steps.ghcr-tag.outputs.tags != 0
0 commit comments