Skip to content

Commit

Permalink
Fix GitHub actions to work a little better
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-claudia committed Sep 2, 2024
1 parent 9e096f3 commit 471d71c
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 70 deletions.
21 changes: 0 additions & 21 deletions .github/actions/setup/action.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/_npm-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Run npm task

on:
workflow_call:
inputs:
task:
type: string
required: true
node-version:
type: number
default: 20
continue-on-error:
type: boolean
default: false

permissions:
contents: read

# This uses actions/checkout instead of `git clone` directly since it's way
# easier than parsing everything out.

jobs:
run-task:
name: npm run ${{ inputs.task }}
continue-on-error: ${{ inputs.continue-on-error }}
runs-on:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- run: npm ci
- run: npm run ${{ inputs.task }}
21 changes: 21 additions & 0 deletions .github/workflows/_post-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Post comment

on:
workflow_call:
inputs:
url:
type: string
required: true
message:
type: string
required: true

jobs:
notify:
runs-on: ubuntu-latest
steps:
- run: gh issue comment "$ISSUE_URL" --body "$MESSAGE"
env:
ISSUE_URL: ${{ inputs.url }}
MESSAGE: ${{ inputs.message }}
GITHUB_TOKEN: ${{ github.token }}
13 changes: 6 additions & 7 deletions .github/workflows/issue-create.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Ping triage on issue create

on:
issues:
types: [opened]

permissions:
issues: write
jobs:
notify:
runs-on: ubuntu-latest
steps:
- run: gh issue comment ${{ github.event.issue.url }} --body '@MithrilJS/triage Please take a look.'
env:
GITHUB_TOKEN: ${{ github.token }}
uses: ./.github/workflows/_post-comment.yml
with:
url: ${{ github.event.issue.url }}
message: '@MithrilJS/triage Please take a look.'
9 changes: 7 additions & 2 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- run: git clone --depth=1 https://github.com/MithrilJS/mithril.js.git && cd mithril.js
- uses: ./.github/actions/setup
- uses: actions/checkout@v4
with:
ref: next
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- run: npx pr-release merge --target master --source next --commit --force --clean --changelog ./docs/recent-changes.md --compact --minimize-semver-change
env:
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ permissions:
issues: write
jobs:
comment:
runs-on: ubuntu-latest
steps:
- run: |
gh issue comment ${{ github.event.pull_request.url }} \
--body '⚠⚠⚠ Hey @${{ github.actor }}, did you mean to open this against `next`? ⚠⚠⚠'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Post alert comment
uses: ./.github/workflows/_post-comment.yml
with:
url: ${{ github.event.pull_request.url }}
message: ⚠⚠⚠ Hey @${{ github.actor }}, did you mean to open this against `next`? ⚠⚠⚠
7 changes: 5 additions & 2 deletions .github/workflows/rollback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- run: git clone --depth=1 https://github.com/MithrilJS/mithril.js.git && cd mithril.js
- uses: ./.github/actions/setup
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- run: npx pr-release rollback --verbose --target master --source next --verbose --ignore 'package*' --ignore docs/changelog.md --ignore docs/recent-changes.md
env:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/test-next-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ on:
concurrency: prr:pre-release

jobs:
build:
test:
uses: ./.github/workflows/test.yml

publish-prerelease:
needs: build
needs: test
runs-on: ubuntu-latest
steps:
- run: git clone --depth=1 https://github.com/MithrilJS/mithril.js.git && cd mithril.js
- uses: ./.github/actions/setup
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- run: npx pr-release pr --verbose --target master --source next --compact --verbose --minimize-semver-change
env:
Expand Down
40 changes: 14 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,24 @@ permissions:

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

lint-js:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: npm run lint:js
uses: ./.github/workflows/_npm-task.yml
with:
task: lint:js

build-js:
needs: lint-js
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: npm run build
uses: ./.github/workflows/_npm-task.yml
with:
task: build

test-js:
needs: build-js
runs-on: ubuntu-latest
strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
Expand All @@ -51,9 +41,7 @@ jobs:
- 18
- 20
- 22
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node-version }}
- run: npm run test:js
uses: ./.github/workflows/_npm-task.yml
with:
node-version: ${{ matrix.node-version }}
task: test:js

0 comments on commit 471d71c

Please sign in to comment.