Fix GitHub actions to work a little better

This commit is contained in:
Claudia Meadows 2024-09-02 10:12:15 -07:00
parent a4db1a1116
commit 57c331c6b4
No known key found for this signature in database
GPG key ID: C86B594396786760
9 changed files with 102 additions and 70 deletions

View file

@ -1,21 +0,0 @@
# In the future, I'd like to fold this into its own action under the Mithril.js
# org and include `actions/checkout` as well. It'd simplify maintenance a bit
# and I could reuse it across multiple repos.
name: Setup CI context
description: Sets up repo and Node context and installs packages
inputs:
# See supported Node.js release schedule here:
# https://github.com/nodejs/Release
node-version:
default: 20
description: The Node version to use
runs:
using: composite
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- run: npm ci
shell: bash

38
.github/workflows/_npm-task.yml vendored Normal file
View file

@ -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
.github/workflows/_post-comment.yml vendored Normal file
View file

@ -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 }}

View file

@ -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.'

View file

@ -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:

View file

@ -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`? ⚠⚠⚠

View file

@ -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:

View file

@ -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:

View file

@ -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/
@ -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