1
1
name : CI
2
2
3
3
on :
4
+ push :
5
+ branches :
6
+ - ' main'
7
+ - ' hotfix**'
4
8
pull_request :
5
- types : [opened, reopened, synchronize, closed ]
9
+ types : [opened, reopened, synchronize]
6
10
paths-ignore : # ignore docs only changes since they use a dedicated workflows: docs.yml
7
11
- ' docs/**'
8
12
- ' mithril-explorer/**'
9
13
- ' .github/workflows/docs.yml'
14
+ branches-ignore :
15
+ - ' hotfix**' # hotfix are handled by the push trigger
10
16
11
17
concurrency :
12
18
group : ci-build-test-${{ github.ref }}
@@ -248,7 +254,7 @@ jobs:
248
254
packages : write
249
255
250
256
env :
251
- PUSH_PACKAGES : ${{ github.event.action == 'closed ' && github.event.pull_request.merged == true && (github.base_ref == 'main' || startsWith('hotfix', github.base_ref )) }}
257
+ PUSH_PACKAGES : ${{ github.event_name == 'push ' && (github.ref == 'refs/heads/ main' || startsWith('refs/heads/ hotfix', github.ref )) }}
252
258
REGISTRY : ghcr.io
253
259
IMAGE_NAME : ${{ github.repository_owner }}/${{ matrix.project }}
254
260
DOCKER_FILE : ./${{ matrix.project }}/Dockerfile.ci
@@ -272,7 +278,7 @@ jobs:
272
278
images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
273
279
tags : |
274
280
unstable
275
- type=raw,value=${{ github.base_ref }}-{{sha}}
281
+ type=raw,value=${{ github.base_ref || github.ref_name }}-{{sha}}
276
282
277
283
- name : Download built artifacts
278
284
uses : actions/download-artifact@v3
@@ -289,7 +295,7 @@ jobs:
289
295
tags : ${{ steps.meta.outputs.tags }}
290
296
291
297
unstable-release :
292
- if : github.event.action == 'closed ' && github.event.pull_request.merged == true && (github.base_ref == 'main' || startsWith('hotfix', github.base_ref ))
298
+ if : github.event_name == 'push ' && (github.ref == 'refs/heads/ main' || startsWith('refs/heads/ hotfix', github.ref ))
293
299
runs-on : ubuntu-22.04
294
300
needs :
295
301
- build
@@ -365,6 +371,8 @@ jobs:
365
371
files : package/*
366
372
367
373
deploy-testing :
374
+ # Don't run on pull request from forks since they don't have access to all the needed secrets
375
+ if : github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork)
368
376
strategy :
369
377
fail-fast : false
370
378
matrix :
@@ -418,7 +426,7 @@ jobs:
418
426
uses : actions/checkout@v3
419
427
420
428
- name : Get Docker image id
421
- run : echo "DOCKER_IMAGE_ID=${{ github.base_ref }}-$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
429
+ run : echo "DOCKER_IMAGE_ID=${{ github.base_ref || github.ref_name }}-$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
422
430
423
431
- name : Prepare service account credentials
424
432
run : |
@@ -462,7 +470,7 @@ jobs:
462
470
GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform plan --var-file=./env.variables.tfvars
463
471
464
472
- name : Terraform Apply
465
- if : github.event.action == 'closed ' && github.event.pull_request.merged == true && github.base_ref == ' main'
473
+ if : github.event_name == 'push ' && github.ref == 'refs/heads/ main'
466
474
run : |
467
475
GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform apply -auto-approve --var-file=./env.variables.tfvars
468
476
0 commit comments