Skip to content

Commit 431aea2

Browse files
committed
Fix GitHub actions to work a little better
1 parent 7083d43 commit 431aea2

File tree

9 files changed

+102
-70
lines changed

9 files changed

+102
-70
lines changed

actions/setup/action.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

workflows/_npm-task.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Run npm task
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
task:
7+
type: string
8+
required: true
9+
node-version:
10+
type: number
11+
default: 20
12+
continue-on-error:
13+
type: boolean
14+
default: false
15+
16+
permissions:
17+
contents: read
18+
19+
# This uses actions/checkout instead of `git clone` directly since it's way
20+
# easier than parsing everything out.
21+
22+
jobs:
23+
run-task:
24+
name: npm run ${{ inputs.task }}
25+
continue-on-error: ${{ inputs.continue-on-error }}
26+
runs-on:
27+
- ubuntu-latest
28+
- windows-latest
29+
- macos-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 1
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: ${{ inputs.node-version }}
37+
- run: npm ci
38+
- run: npm run ${{ inputs.task }}

workflows/_post-comment.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Post comment
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
url:
7+
type: string
8+
required: true
9+
message:
10+
type: string
11+
required: true
12+
13+
jobs:
14+
notify:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- run: gh issue comment "$ISSUE_URL" --body "$MESSAGE"
18+
env:
19+
ISSUE_URL: ${{ inputs.url }}
20+
MESSAGE: ${{ inputs.message }}
21+
GITHUB_TOKEN: ${{ github.token }}

workflows/issue-create.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
name: Ping triage on issue create
2-
32
on:
43
issues:
54
types: [opened]
6-
5+
permissions:
6+
issues: write
77
jobs:
88
notify:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- run: gh issue comment ${{ github.event.issue.url }} --body '@MithrilJS/triage Please take a look.'
12-
env:
13-
GITHUB_TOKEN: ${{ github.token }}
9+
uses: ./.github/workflows/_post-comment.yml
10+
with:
11+
url: ${{ github.event.issue.url }}
12+
message: '@MithrilJS/triage Please take a look.'

workflows/merge.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- run: git clone --depth=1 https://github.com/MithrilJS/mithril.js.git && cd mithril.js
17-
- uses: ./.github/actions/setup
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: next
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
- run: npm ci
1823
- run: npm run build
1924
- run: npx pr-release merge --target master --source next --commit --force --clean --changelog ./docs/recent-changes.md --compact --minimize-semver-change
2025
env:

workflows/push-master.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ permissions:
77
issues: write
88
jobs:
99
comment:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- run: |
13-
gh issue comment ${{ github.event.pull_request.url }} \
14-
--body '⚠⚠⚠ Hey @${{ github.actor }}, did you mean to open this against `next`? ⚠⚠⚠'
15-
env:
16-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17-
name: Post alert comment
10+
uses: ./.github/workflows/_post-comment.yml
11+
with:
12+
url: ${{ github.event.pull_request.url }}
13+
message: ⚠⚠⚠ Hey @${{ github.actor }}, did you mean to open this against `next`? ⚠⚠⚠

workflows/rollback.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- run: git clone --depth=1 https://github.com/MithrilJS/mithril.js.git && cd mithril.js
14-
- uses: ./.github/actions/setup
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
- run: npm ci
1518
- run: npm run build
1619
- run: npx pr-release rollback --verbose --target master --source next --verbose --ignore 'package*' --ignore docs/changelog.md --ignore docs/recent-changes.md
1720
env:

workflows/test-next-push.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ on:
88
concurrency: prr:pre-release
99

1010
jobs:
11-
build:
11+
test:
1212
uses: ./.github/workflows/test.yml
1313

1414
publish-prerelease:
15-
needs: build
15+
needs: test
1616
runs-on: ubuntu-latest
1717
steps:
18-
- run: git clone --depth=1 https://github.com/MithrilJS/mithril.js.git && cd mithril.js
19-
- uses: ./.github/actions/setup
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
- run: npm ci
2023
- run: npm run build
2124
- run: npx pr-release pr --verbose --target master --source next --compact --verbose --minimize-semver-change
2225
env:

workflows/test.yml

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,24 @@ permissions:
1515

1616
jobs:
1717
lint-docs:
18-
# https://github.com/MithrilJS/mithril.js/issues/2898
19-
# Semantics aren't quite what I'd prefer. This is what I'd really want:
20-
# https://github.com/actions/runner/issues/2347#issue-comment-box
21-
continue-on-error: true
22-
runs-on: ubuntu-latest
23-
steps:
24-
- uses: actions/checkout@v4
25-
- uses: ./.github/actions/setup
26-
- run: npm run lint:docs
18+
uses: ./.github/workflows/_npm-task.yml
19+
with:
20+
task: lint:docs
21+
continue-on-error: true
2722

2823
lint-js:
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/checkout@v4
32-
- uses: ./.github/actions/setup
33-
- run: npm run lint:js
24+
uses: ./.github/workflows/_npm-task.yml
25+
with:
26+
task: lint:js
3427

3528
build-js:
3629
needs: lint-js
37-
runs-on: ubuntu-latest
38-
steps:
39-
- uses: actions/checkout@v4
40-
- uses: ./.github/actions/setup
41-
- run: npm run build
30+
uses: ./.github/workflows/_npm-task.yml
31+
with:
32+
task: build
4233

4334
test-js:
4435
needs: build-js
45-
runs-on: ubuntu-latest
4636
strategy:
4737
matrix:
4838
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
@@ -51,9 +41,7 @@ jobs:
5141
- 18
5242
- 20
5343
- 22
54-
steps:
55-
- uses: actions/checkout@v4
56-
- uses: ./.github/actions/setup
57-
with:
58-
node-version: ${{ matrix.node-version }}
59-
- run: npm run test:js
44+
uses: ./.github/workflows/_npm-task.yml
45+
with:
46+
node-version: ${{ matrix.node-version }}
47+
task: test:js

0 commit comments

Comments
 (0)