Skip to content

Commit 97816e2

Browse files
committed
Switch ci & doc workflow to pull_request trigger
1 parent aa31261 commit 97816e2

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

.github/workflows/ci.yml

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

33
on:
4-
push:
5-
branches: # only run on branch push, tag push will be ignored
6-
- '**'
4+
pull_request:
5+
types: [opened, reopened, synchronize, closed]
76
paths-ignore: # ignore docs only changes since they use a dedicated workflows: docs.yml
87
- 'docs/**'
98
- 'mithril-explorer/**'
@@ -249,12 +248,11 @@ jobs:
249248
packages: write
250249

251250
env:
252-
PUSH_PACKAGES: ${{ github.ref == 'refs/heads/main' || startsWith('refs/heads/hotfix', github.ref) }}
251+
PUSH_PACKAGES: ${{ github.event.action == 'closed' && github.event.pull_request.merged == true && (github.base_ref == 'refs/heads/main' || startsWith('refs/heads/hotfix', github.base_ref)) }}
253252
REGISTRY: ghcr.io
254253
IMAGE_NAME: ${{ github.repository_owner }}/${{ matrix.project }}
255254
DOCKER_FILE: ./${{ matrix.project }}/Dockerfile.ci
256255
CONTEXT: .
257-
GITHUB_REF: ${{ github.ref}}
258256

259257
steps:
260258
- name: Checkout
@@ -274,7 +272,7 @@ jobs:
274272
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
275273
tags: |
276274
unstable
277-
type=raw,value={{branch}}-{{sha}}
275+
type=raw,value={{base_ref}}-{{sha}}
278276
279277
- name: Download built artifacts
280278
uses: actions/download-artifact@v3
@@ -291,7 +289,7 @@ jobs:
291289
tags: ${{ steps.meta.outputs.tags }}
292290

293291
unstable-release:
294-
if: github.ref == 'refs/heads/main' || startsWith('refs/heads/hotfix', github.ref)
292+
if: github.event.action == 'closed' && github.event.pull_request.merged == true && (github.base_ref == 'refs/heads/main' || startsWith('refs/heads/hotfix', github.base_ref))
295293
runs-on: ubuntu-22.04
296294
needs:
297295
- build
@@ -460,7 +458,7 @@ jobs:
460458
GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform plan --var-file=./env.variables.tfvars
461459
462460
- name: Terraform Apply
463-
if: github.ref == 'refs/heads/main'
461+
if: github.event.action == 'closed' && github.event.pull_request.merged == true && github.base_ref == 'refs/heads/main'
464462
run: |
465463
GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform apply -auto-approve --var-file=./env.variables.tfvars
466464

.github/workflows/docs.yml

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

33
on:
4-
push:
5-
branches: # only run on branch push, tag push will be ignored
6-
- '**'
4+
pull_request:
5+
types: [opened, reopened, synchronize, closed]
76

87
concurrency:
98
group: ci-docs-${{ github.ref }}
@@ -117,7 +116,7 @@ jobs:
117116
out/*
118117
119118
publish-docs:
120-
if: github.ref == 'refs/heads/main'
119+
if: github.event.action == 'closed' && github.event.pull_request.merged == true && github.base_ref == 'refs/heads/main'
121120
runs-on: ubuntu-22.04
122121
needs:
123122
- cargo-doc

0 commit comments

Comments
 (0)