Skip to content

Commit db471a5

Browse files
author
Lukas Puehringer
committed
Refactor ci/cd workflows
Prior to this change, ci triggered cd, depending on the event that triggered ci. Due to the vague information about that event available to cd, the workflow pipeline was a bit brittle. This change disassociates ci and cd workflows to allow for an independent configuration of trigger events. The test jobs, which used to be defined in ci, are now in a separate workflow file _test.yml that can be included in both ci and cd workflows. **Changes in ci** - Only defines trigger events and permissions, the "meat" of ci is defined in the called _test.yml now. - No longer triggers on tag pushes, this was only needed for cd. **Changes in cd** - Now triggers directly on tag pushes instead of (cd)-workflow_run. - Calls _test.yml, and require successful run before build/release. (`needs: test` replaces `if: ...`) - Changes variable names about pushed tag that triggered the event. Signed-off-by: Lukas Puehringer <[email protected]>
1 parent 38b774e commit db471a5

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

.github/workflows/_test.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
name: CI
2-
31
on:
4-
# NOTE: CD relies on this configuration (see #1961)
5-
push:
6-
branches:
7-
- develop
8-
tags:
9-
- v*
10-
11-
pull_request:
12-
workflow_dispatch:
2+
workflow_call:
3+
# Permissions inherited from caller workflow
134

14-
permissions:
15-
contents: read
165

176
jobs:
187
tests:

.github/workflows/cd.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
name: CD
22
concurrency: cd
33

4-
# Trigger workflow on any completed CI (see further checks below)
54
on:
6-
workflow_run:
7-
workflows: [CI]
8-
types: [completed]
5+
push:
6+
tags:
7+
- v*
8+
99

1010
jobs:
11+
test:
12+
uses: ./.github/workflows/_test.yml
13+
1114
build:
1215
name: Build
1316
runs-on: ubuntu-latest
14-
# Skip unless CI was successful and ran on release tag, a ref starting with 'v'.
15-
# NOTE: We assume CI does not trigger on branches that start with 'v' (see #1961)
16-
if: >-
17-
github.event.workflow_run.conclusion == 'success' &&
18-
startsWith(github.event.workflow_run.head_branch, 'v')
17+
needs: test
1918
outputs:
2019
release_id: ${{ steps.gh-release.outputs.id }}
2120
steps:
@@ -39,8 +38,8 @@ jobs:
3938
name: Publish GitHub release candiate
4039
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
4140
with:
42-
name: ${{ github.event.workflow_run.head_branch }}-rc
43-
tag_name: ${{ github.event.workflow_run.head_branch }}
41+
name: ${{ github.ref_name }}-rc
42+
tag_name: ${{ github.ref }}
4443
body: "Release waiting for review..."
4544
files: dist/*
4645

@@ -79,9 +78,8 @@ jobs:
7978
owner: context.repo.owner,
8079
repo: context.repo.repo,
8180
release_id: '${{ needs.build.outputs.release_id }}',
82-
name: '${{ github.event.workflow_run.head_branch }}',
81+
name: '${{ github.ref_name }}',
8382
body: 'See [CHANGELOG.md](https://github.com/' +
84-
context.repo.owner + '/' + context.repo.repo + '/blob/' +
85-
'${{ github.event.workflow_run.head_branch }}'+
86-
'/docs/CHANGELOG.md) for details.'
83+
context.repo.owner + '/' + context.repo.repo +
84+
'/blob/${{ github.ref_name }}/docs/CHANGELOG.md) for details.'
8785
})

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
pull_request:
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
test:
16+
uses: ./.github/workflows/_test.yml

0 commit comments

Comments
 (0)