Skip to content

Commit ab3643c

Browse files
committed
Deploy & push docker on push trigger to main or hotfix
Instead of using the pull_request trigger, meaning that only branches coming directly from the repository will trigger push & deploy
1 parent 5b0de28 commit ab3643c

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
name: CI
22

33
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'hotfix**'
48
pull_request:
5-
types: [opened, reopened, synchronize, closed]
9+
types: [opened, reopened, synchronize]
610
paths-ignore: # ignore docs only changes since they use a dedicated workflows: docs.yml
711
- 'docs/**'
812
- 'mithril-explorer/**'
913
- '.github/workflows/docs.yml'
14+
branches-ignore:
15+
- 'hotfix**' # hotfix are handled by the push trigger
1016

1117
concurrency:
1218
group: ci-build-test-${{ github.ref }}
@@ -248,7 +254,7 @@ jobs:
248254
packages: write
249255

250256
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)) }}
252258
REGISTRY: ghcr.io
253259
IMAGE_NAME: ${{ github.repository_owner }}/${{ matrix.project }}
254260
DOCKER_FILE: ./${{ matrix.project }}/Dockerfile.ci
@@ -272,7 +278,7 @@ jobs:
272278
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
273279
tags: |
274280
unstable
275-
type=raw,value=${{ github.base_ref }}-{{sha}}
281+
type=raw,value=${{ github.base_ref || github.ref_name }}-{{sha}}
276282
277283
- name: Download built artifacts
278284
uses: actions/download-artifact@v3
@@ -289,7 +295,7 @@ jobs:
289295
tags: ${{ steps.meta.outputs.tags }}
290296

291297
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))
293299
runs-on: ubuntu-22.04
294300
needs:
295301
- build
@@ -418,7 +424,7 @@ jobs:
418424
uses: actions/checkout@v3
419425

420426
- name: Get Docker image id
421-
run: echo "DOCKER_IMAGE_ID=${{ github.base_ref }}-$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
427+
run: echo "DOCKER_IMAGE_ID=${{ github.base_ref || github.ref_name }}-$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
422428

423429
- name: Prepare service account credentials
424430
run: |
@@ -462,7 +468,7 @@ jobs:
462468
GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform plan --var-file=./env.variables.tfvars
463469
464470
- name: Terraform Apply
465-
if: github.event.action == 'closed' && github.event.pull_request.merged == true && github.base_ref == 'main'
471+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
466472
run: |
467473
GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform apply -auto-approve --var-file=./env.variables.tfvars
468474

.github/workflows/docs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
name: Documentations & Explorer
22

33
on:
4+
push:
5+
branches:
6+
- 'main'
47
pull_request:
5-
types: [opened, reopened, synchronize, closed]
8+
types: [opened, reopened, synchronize]
69

710
concurrency:
811
group: ci-docs-${{ github.ref }}
@@ -116,7 +119,7 @@ jobs:
116119
out/*
117120
118121
publish-docs:
119-
if: github.event.action == 'closed' && github.event.pull_request.merged == true && github.base_ref == 'main'
122+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
120123
runs-on: ubuntu-22.04
121124
needs:
122125
- cargo-doc

0 commit comments

Comments
 (0)