Skip to content

Commit add19aa

Browse files
committed
ci: improve workflow triggers
- Unchain commit-lint and CI: Even if a commit does not meet the CI path filter, it still needs to lint the commit message. - Unchain PR filter and CI: The CI workflow needs to be triggered when the commits in a pull request are modified. - Allow manual publishing: Sometimes `semantic-release` will error out due to commit messages referencing discussions, but this does not affect the final RubyGems/GitHub Release. In such cases, manual triggering of the publish process is needed to complete the remaining publishing steps.
1 parent c7f9675 commit add19aa

File tree

7 files changed

+29
-34
lines changed

7 files changed

+29
-34
lines changed

.github/workflows/cd.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ name: CD
22

33
on:
44
push:
5-
branches:
6-
- production
7-
tags-ignore:
8-
- "**"
5+
branches: [production]
6+
tags-ignore: ["**"]
97

108
jobs:
119
release:
10+
if: ${{ ! startsWith(github.event.head_commit.message, 'chore(release)') }}
1211
permissions:
1312
contents: write
1413
issues: write

.github/workflows/ci.yml

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

33
on:
44
push:
5-
branches:
6-
- "master"
7-
- "hotfix/**"
5+
branches-ignore: [production]
86
paths-ignore:
97
- ".github/**"
108
- "!.github/workflows/ci.yml"
11-
- ".gitignore"
9+
- .gitignore
1210
- "docs/**"
13-
- "README.md"
14-
- "LICENSE"
15-
workflow_call:
11+
- README.md
12+
- LICENSE
13+
pull_request:
14+
paths-ignore:
15+
- ".github/**"
16+
- "!.github/workflows/ci.yml"
17+
- .gitignore
18+
- "docs/**"
19+
- README.md
20+
- LICENSE
1621

1722
jobs:
1823
build:
@@ -44,7 +49,3 @@ jobs:
4449

4550
- name: Test Site
4651
run: bash tools/test.sh
47-
48-
check-commit:
49-
needs: build
50-
uses: ./.github/workflows/commitlint.yml

.github/workflows/commitlint.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Lint Commit Messages
22

3-
on: workflow_call
3+
on:
4+
push:
5+
branches-ignore: [production]
6+
pull_request:
47

58
jobs:
69
commitlint:

.github/workflows/pr-filter.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ jobs:
1919
uses: actions/github-script@v7
2020
with:
2121
github-token: ${{ secrets.GITHUB_TOKEN }}
22-
result-encoding: string
2322
script: |
2423
const script = require('.github/workflows/scripts/pr-filter.js');
25-
return await script({ github, context });
26-
27-
- name: Abort due to invalid PR
28-
if: ${{ steps.intercept.outputs.result != 'true' }}
29-
run: exit 1
30-
31-
test:
32-
needs: check-template
33-
uses: ./.github/workflows/ci.yml
24+
await script({ github, context, core });

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
required: true
1111
BUILDER:
1212
required: true
13+
workflow_dispatch:
1314

1415
jobs:
1516
launch:

.github/workflows/scripts/pr-filter.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function hasTypes(markdown) {
2-
return /## Type of change/.test(markdown) && /-\s*\[x\]/i.test(markdown);
2+
return /## Type of change/.test(markdown) && /-\s\[x\]/i.test(markdown);
33
}
44

55
function hasDescription(markdown) {
@@ -9,9 +9,9 @@ function hasDescription(markdown) {
99
);
1010
}
1111

12-
module.exports = async ({ github, context }) => {
12+
module.exports = async ({ github, context, core }) => {
1313
const pr = context.payload.pull_request;
14-
const body = pr.body === null ? '' : pr.body.trim();
14+
const body = pr.body === null ? '' : pr.body;
1515
const markdown = body.replace(/<!--[\s\S]*?-->/g, '');
1616
const action = context.payload.action;
1717

@@ -31,7 +31,7 @@ module.exports = async ({ github, context }) => {
3131
issue_number: pr.number,
3232
body: `Oops, it seems you've ${action} an invalid pull request. No worries, we'll close it for you.`
3333
});
34-
}
3534

36-
return isValid;
35+
core.setFailed('PR content does not meet template requirements.');
36+
}
3737
};

.github/workflows/style-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: "Style Lint"
1+
name: Style Lint
22

33
on:
44
push:
5-
branches: ["master", "hotfix/**"]
5+
branches-ignore: [production]
66
paths: ["_sass/**/*.scss"]
77
pull_request:
88
paths: ["_sass/**/*.scss"]

0 commit comments

Comments
 (0)