Skip to content

Commit 42d9bd9

Browse files
authored
Merge pull request #629 from input-output-hk/djo/597/deploy-using-push-trigger
Deploy using push trigger
2 parents cc11d03 + e92abf6 commit 42d9bd9

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

.github/workflows/ci.yml

Lines changed: 14 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
@@ -365,6 +371,8 @@ jobs:
365371
files: package/*
366372

367373
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)
368376
strategy:
369377
fail-fast: false
370378
matrix:
@@ -418,7 +426,7 @@ jobs:
418426
uses: actions/checkout@v3
419427

420428
- 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
422430

423431
- name: Prepare service account credentials
424432
run: |
@@ -462,7 +470,7 @@ jobs:
462470
GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform plan --var-file=./env.variables.tfvars
463471
464472
- 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'
466474
run: |
467475
GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform apply -auto-approve --var-file=./env.variables.tfvars
468476

.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

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,11 @@ jobs:
110110
command: package
111111
args: -p mithril-stm --list
112112

113-
# We use the '--dry-run' arg until we have a valid CRATES_IO_API_TOKEN to avoid the workflow to crash
114113
- name: Cargo publish
115114
uses: actions-rs/cargo@v1
116115
with:
117116
command: publish
118-
args: -p mithril-stm --token ${{ secrets.CRATES_IO_API_TOKEN }} --dry-run
117+
args: -p mithril-stm --token ${{ secrets.CRATES_IO_API_TOKEN }}
119118

120119
deploy-release:
121120
strategy:

0 commit comments

Comments
 (0)