@@ -106,118 +106,103 @@ 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
182- yarn install
183-
184126 # setup zodern:types. No linters are setup, so this simply installs the packages
185127 yarn meteor lint
128+
129+ yarn install
186130 - name : Build libs
187- if : steps.check-build-and-push.outputs.enable == 'true'
188131 run : |
189132 yarn build:packages
190133 - name : Persist Built Version information
191- if : steps.check-build-and-push.outputs.enable == 'true'
192134 run : |
193135 cd meteor
194136 yarn inject-git-hash
195137 - name : Prepare webui for meteor build
196- if : steps.check-build-and-push.outputs.enable == 'true'
197138 run : |
198139 rm -Rf meteor/public
199140 cp -R packages/webui/dist meteor/public
200141 - name : Meteor Build
201- if : steps.check-build-and-push.outputs.enable == 'true'
202142 run : |
203143 cd meteor
204144 NODE_OPTIONS="--max-old-space-size=4096" METEOR_DEBUG_BUILD=1 meteor build --allow-superuser --directory .
205145 mv bundle/programs/web.browser/assets/ bundle/programs/web.browser/app/assets/ || true
206-
207146 - name : Meteor Bundle NPM Build
208- if : steps.check-build-and-push.outputs.enable == 'true'
209147 run : |
210148 cd meteor/bundle/programs/server
211149 meteor npm install
212150 - name : Set up Docker Buildx
213- if : steps.check-build-and-push.outputs.enable == 'true'
214151 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
152+
153+ # Check how the image should be built and pushed
154+ - name : Determine if images should be published to DockerHub
155+ id : dockerhub
156+ run : |
157+ # check if a release branch, or main, or a tag
158+ if [[ "${{ github.ref }}" =~ ^refs/heads/release([0-9]+)$ || "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == refs/tags/* ]]
159+ then
160+ DOCKERHUB_PUBLISH="1"
161+ else
162+ DOCKERHUB_PUBLISH="0"
163+ fi
164+ # debug output
165+ echo "dockerhub-publish $DOCKERHUB_PUBLISH"
166+ echo "dockerhub-publish=$DOCKERHUB_PUBLISH" >> $GITHUB_OUTPUT
167+ - name : Check if push to GHCR is enabled
168+ id : check-ghcr
169+ env :
170+ GHCR_ENABLED : ${{ secrets.GHCR_ENABLED }}
171+ run : |
172+ echo "Enable push to GHCR: ${{ env.GHCR_ENABLED != '' }}"
173+ echo "enable=${{ env.GHCR_ENABLED != '' }}" >> $GITHUB_OUTPUT
174+ - name : Check if there is access to repo secrets (needed for build and push)
175+ if : steps.dockerhub.outputs.dockerhub-publish == '1' || steps.check-ghcr.outputs.enable == 'true'
176+ id : check-build-and-push
177+ env :
178+ SECRET_ACCESS : ${{ secrets.DOCKERHUB_IMAGE_PREFIX }}
179+ run : |
180+ echo "Enable build and push: ${{ env.SECRET_ACCESS != '' }}"
181+ echo "enable=${{ env.SECRET_ACCESS != '' }}" >> $GITHUB_OUTPUT
182+
183+ # No-push build if no destination
184+ - name : Build without push
185+ if : steps.check-build-and-push.outputs.enable != 'true'
186+ uses : docker/build-push-action@v6
218187 with :
219- username : ${{ secrets.DOCKERHUB_USERNAME }}
220- password : ${{ secrets.DOCKERHUB_TOKEN }}
188+ context : .
189+ file : ./meteor/Dockerfile.circle
190+ push : false
191+ provenance : false
192+
193+ # GHCR build
194+ - name : Get the Docker tag for GHCR
195+ id : ghcr-tag
196+ if : steps.check-build-and-push.outputs.enable == 'true'
197+ uses : docker/metadata-action@v5
198+ with :
199+ images : |
200+ ghcr.io/${{ github.repository }}-server-core
201+ tags : |
202+ type=schedule
203+ type=ref,event=branch
204+ type=ref,event=tag
205+ type=raw,value=latest,enable={{is_default_branch}}
221206 - name : Login to GitHub Container Registry
222207 if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true'
223208 uses : docker/login-action@v3
@@ -236,6 +221,26 @@ jobs:
236221 labels : ${{ steps.ghcr-tag.outputs.labels }}
237222 tags : " ${{ steps.ghcr-tag.outputs.tags }}"
238223 github-token : ${{ github.token }}
224+
225+ # Dockerhub push
226+ - name : Get the Docker tag for DockerHub
227+ id : dockerhub-tag
228+ if : steps.check-build-and-push.outputs.enable == 'true'
229+ uses : docker/metadata-action@v5
230+ with :
231+ images : |
232+ ${{ secrets.DOCKERHUB_IMAGE_PREFIX }}server-core
233+ tags : |
234+ type=schedule
235+ type=ref,event=branch
236+ type=ref,event=tag
237+ type=raw,value=latest,enable={{is_default_branch}}
238+ - name : Login to DockerHub
239+ if : steps.check-build-and-push.outputs.enable == 'true' && steps.dockerhub.outputs.dockerhub-publish == '1'
240+ uses : docker/login-action@v3
241+ with :
242+ username : ${{ secrets.DOCKERHUB_USERNAME }}
243+ password : ${{ secrets.DOCKERHUB_TOKEN }}
239244 - name : Build and push to DockerHub
240245 if : steps.check-build-and-push.outputs.enable == 'true' && steps.dockerhub.outputs.dockerhub-publish == '1'
241246 uses : docker/build-push-action@v6
@@ -246,6 +251,8 @@ jobs:
246251 provenance : false
247252 labels : ${{ steps.dockerhub-tag.outputs.labels }}
248253 tags : ${{ steps.dockerhub-tag.outputs.tags }}
254+
255+ # Trivy scanning
249256 - name : Get image for Trivy scanning
250257 id : trivy-image
251258 if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true' && steps.ghcr-tag.outputs.tags != 0
@@ -289,6 +296,30 @@ jobs:
289296 - uses : actions/checkout@v6
290297 with :
291298 persist-credentials : false
299+
300+ - name : Use Node.js
301+ uses : actions/setup-node@v6
302+ with :
303+ node-version-file : " .node-version"
304+ - name : restore node_modules
305+ uses : actions/cache@v4
306+ with :
307+ path : |
308+ packages/node_modules
309+ key : ${{ runner.os }}-${{ hashFiles('packages/yarn.lock') }}
310+ - name : Build
311+ run : |
312+ corepack enable
313+
314+ cd packages
315+ yarn install
316+ yarn build:single ${{ matrix.gateway-name }}/tsconfig.build.json
317+ yarn run pinst --disable
318+ yarn workspaces focus ${{ matrix.gateway-name }} --production
319+ - name : Set up Docker Buildx
320+ uses : docker/setup-buildx-action@v3
321+
322+ # Check how the image should be built and pushed
292323 - name : Determine if images should be published to DockerHub
293324 id : dockerhub
294325 run : |
@@ -317,6 +348,18 @@ jobs:
317348 run : |
318349 echo "Enable build and push: ${{ env.SECRET_ACCESS != '' }}"
319350 echo "enable=${{ env.SECRET_ACCESS != '' }}" >> $GITHUB_OUTPUT
351+
352+ # No-push build if no destination
353+ - name : Build without push
354+ if : steps.check-build-and-push.outputs.enable != 'true'
355+ uses : docker/build-push-action@v6
356+ with :
357+ context : ./packages
358+ file : ./packages/${{ matrix.gateway-name }}/Dockerfile.circle
359+ push : false
360+ provenance : false
361+
362+ # GHCR build
320363 - name : Get the Docker tag for GHCR
321364 id : ghcr-tag
322365 if : steps.check-build-and-push.outputs.enable == 'true'
@@ -329,6 +372,25 @@ jobs:
329372 type=ref,event=branch
330373 type=ref,event=tag
331374 type=raw,value=latest,enable={{is_default_branch}}
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 }}"
392+
393+ # Dockerhub push
332394 - name : Get the Docker tag for DockerHub
333395 id : dockerhub-tag
334396 if : steps.check-build-and-push.outputs.enable == 'true'
@@ -341,54 +403,12 @@ jobs:
341403 type=ref,event=branch
342404 type=ref,event=tag
343405 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
369406 - name : Login to DockerHub
370407 if : steps.check-build-and-push.outputs.enable == 'true' && steps.dockerhub.outputs.dockerhub-publish == '1'
371408 uses : docker/login-action@v3
372409 with :
373410 username : ${{ secrets.DOCKERHUB_USERNAME }}
374411 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 }}"
392412 - name : Build and push to DockerHub
393413 if : steps.check-build-and-push.outputs.enable == 'true' && steps.dockerhub.outputs.dockerhub-publish == '1'
394414 uses : docker/build-push-action@v6
@@ -399,6 +419,8 @@ jobs:
399419 provenance : false
400420 labels : ${{ steps.dockerhub-tag.outputs.labels }}
401421 tags : " ${{ steps.dockerhub-tag.outputs.tags }}"
422+
423+ # Trivy scanning
402424 - name : Get image for Trivy scanning
403425 id : trivy-image
404426 if : steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true' && steps.ghcr-tag.outputs.tags != 0
0 commit comments