Skip to content

Commit 4ef3cd8

Browse files
authored
ci: improve workflow triggers (cotes2020#2017)
- 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 4ef3cd8

File tree

7 files changed

+34
-33
lines changed

7 files changed

+34
-33
lines changed

.github/workflows/cd.yml

+3-4
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

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
name: "CI"
1+
name: CI
22

33
on:
44
push:
55
branches:
6-
- "master"
7-
- "hotfix/**"
6+
- master
7+
- "hotfix/*"
88
paths-ignore:
99
- ".github/**"
1010
- "!.github/workflows/ci.yml"
11-
- ".gitignore"
11+
- .gitignore
1212
- "docs/**"
13-
- "README.md"
14-
- "LICENSE"
15-
workflow_call:
13+
- README.md
14+
- LICENSE
15+
pull_request:
16+
paths-ignore:
17+
- ".github/**"
18+
- "!.github/workflows/ci.yml"
19+
- .gitignore
20+
- "docs/**"
21+
- README.md
22+
- LICENSE
1623

1724
jobs:
1825
build:
@@ -44,7 +51,3 @@ jobs:
4451

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

.github/workflows/commitlint.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Lint Commit Messages
22

3-
on: workflow_call
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- "hotfix/*"
8+
pull_request:
49

510
jobs:
611
commitlint:

.github/workflows/pr-filter.yml

+1-10
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

+1
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

+5-5
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

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
name: "Style Lint"
1+
name: Style Lint
22

33
on:
44
push:
5-
branches: ["master", "hotfix/**"]
5+
branches:
6+
- master
7+
- "hotfix/*"
68
paths: ["_sass/**/*.scss"]
79
pull_request:
810
paths: ["_sass/**/*.scss"]

0 commit comments

Comments
 (0)