Skip to content

Commit 21687fe

Browse files
Clean up GitHub workflows and Dependabot config
- Fix spellcheck crashing when no Markdown/HTML files change, and drop tj-actions/changed-files in favour of git diff and the repo's cspell - Merge the static analysis jobs into one job that runs the npm scripts - Run pr-auto-update only on pushes to main, and add concurrency groups - Merge the PR label and auto-merge workflows, using the GitHub App token instead of GITHUB_TOKEN and PR_AUTO_UPDATE_TOKEN - Drop Ruby and Autobuild from CodeQL and scan workflow files instead - Use setup-node's npm cache with npm ci - Add npm to Dependabot, cover the composite action, switch to weekly grouped updates and delete the unused root dependabot.yml - Replace the sync label bot comment with a note in CONTRIBUTING.md
1 parent ad304cd commit 21687fe

12 files changed

Lines changed: 188 additions & 216 deletions
Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
name: Setup node
2-
description: Local node setup for runners
1+
name: Set up Node.js
2+
description: Install Node.js and the project's npm dependencies
33

44
runs:
5-
using: "composite"
5+
using: composite
66
steps:
7-
- name: Cache npm and node_modules
8-
uses: actions/cache@v6
9-
with:
10-
path: |
11-
~/.npm
12-
node_modules
13-
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
14-
restore-keys: |
15-
${{ runner.os }}-npm-
7+
- name: Set up Node.js
8+
uses: actions/setup-node@v7
9+
with:
10+
node-version: "24"
11+
cache: npm
1612

17-
- name: Set up Node.js
18-
uses: actions/setup-node@v7
19-
with:
20-
node-version: '24'
21-
22-
- name: Install dependencies
23-
shell: bash
24-
run: npm install
13+
- name: Install dependencies
14+
shell: bash
15+
run: npm ci

‎.github/dependabot.yml‎

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "docker"
4-
directory: "/"
3+
- package-ecosystem: npm
4+
directory: /
55
schedule:
6-
interval: "daily"
6+
interval: weekly
7+
groups:
8+
npm:
9+
patterns: ["*"]
710

8-
- package-ecosystem: "bundler"
9-
directory: "/"
11+
- package-ecosystem: bundler
12+
directory: /
1013
schedule:
11-
interval: "daily"
14+
interval: weekly
15+
groups:
16+
bundler:
17+
patterns: ["*"]
1218

13-
- package-ecosystem: "github-actions"
14-
directory: "/"
19+
- package-ecosystem: docker
20+
directory: /
1521
schedule:
16-
interval: "daily"
22+
interval: weekly
23+
groups:
24+
docker:
25+
patterns: ["*"]
26+
27+
- package-ecosystem: github-actions
28+
# "/" only covers .github/workflows, so the local composite actions are listed too
29+
directories: ["/", "/.github/actions/*"]
30+
schedule:
31+
interval: weekly
32+
groups:
33+
github-actions:
34+
patterns: ["*"]
Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,40 @@
1-
name: "CodeQL"
1+
name: CodeQL
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [main]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: [main]
88
schedule:
9-
- cron: '39 7 * * 6'
9+
- cron: "39 7 * * 6"
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1017

1118
jobs:
1219
analyze:
1320
name: Analyze
1421
runs-on: ubuntu-latest
1522
permissions:
16-
actions: read
1723
contents: read
1824
security-events: write
19-
2025
strategy:
2126
fail-fast: false
2227
matrix:
23-
language: [ 'javascript', 'ruby' ]
24-
28+
language: [actions, javascript]
2529
steps:
26-
- name: Checkout repository
27-
uses: actions/checkout@v7
28-
29-
# Initializes the CodeQL tools for scanning.
30-
- name: Initialize CodeQL
31-
uses: github/codeql-action/init@v4
32-
with:
33-
languages: ${{ matrix.language }}
34-
35-
36-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
37-
# If this step fails, then you should remove it and run the build manually (see below)
38-
- name: Autobuild
39-
uses: github/codeql-action/autobuild@v4
40-
41-
# ℹ️ Command-line programs to run using the OS shell.
42-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
43-
44-
# If the Autobuild fails above, remove it and uncomment the following three lines.
45-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
30+
- name: Checkout repository
31+
uses: actions/checkout@v7
4632

47-
# - run: |
48-
# echo "Run, Build Application using script"
49-
# ./location_of_script_within_repo/buildscript.sh
33+
- name: Initialize CodeQL
34+
uses: github/codeql-action/init@v4
35+
with:
36+
languages: ${{ matrix.language }}
37+
build-mode: none
5038

51-
- name: Perform CodeQL Analysis
52-
uses: github/codeql-action/analyze@v4
39+
- name: Perform CodeQL analysis
40+
uses: github/codeql-action/analyze@v4

‎.github/workflows/pr-auto-label.yml‎

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

‎.github/workflows/pr-auto-merge.yml‎

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: PR auto-setup
2+
3+
# pull_request_target gives fork PRs access to the App secrets. This is safe only
4+
# because no step checks out or runs code from the PR.
5+
on:
6+
pull_request_target:
7+
types: [opened, ready_for_review]
8+
branches: [main]
9+
10+
# The job uses the GitHub App token, not GITHUB_TOKEN
11+
permissions: {}
12+
13+
jobs:
14+
pr-auto-setup:
15+
name: Label and enable auto-merge
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Generate App token
19+
id: app-token
20+
uses: actions/create-github-app-token@v3
21+
with:
22+
client-id: ${{ vars.PR_AUTO_UPDATE_CLIENT_ID }}
23+
private-key: ${{ secrets.PR_AUTO_UPDATE_PRIVATE_KEY }}
24+
25+
# Only for branches in this repo; bots such as Dependabot rebase their own PRs
26+
- name: Add sync label
27+
if: >-
28+
github.event.action == 'opened'
29+
&& github.event.pull_request.head.repo.full_name == github.repository
30+
&& github.event.pull_request.user.type != 'Bot'
31+
run: gh pr edit "$PR_URL" --add-label sync
32+
env:
33+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
34+
PR_URL: ${{ github.event.pull_request.html_url }}
35+
36+
- name: Enable auto-merge
37+
if: ${{ !github.event.pull_request.draft }}
38+
run: gh pr merge "$PR_URL" --auto --squash
39+
env:
40+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
41+
PR_URL: ${{ github.event.pull_request.html_url }}
Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
1-
name: pr-auto-update
1+
name: PR auto-update
2+
23
on:
3-
push: {}
4+
push:
5+
branches: [main]
6+
7+
# The job uses the GitHub App token, not GITHUB_TOKEN
8+
permissions: {}
9+
10+
# Queue rather than cancel, so an update is never stopped part way through
11+
concurrency:
12+
group: ${{ github.workflow }}
13+
cancel-in-progress: false
414

515
jobs:
616
pr-auto-update:
7-
name: Automatic PR Updater
17+
name: Update PRs labelled sync
818
runs-on: ubuntu-latest
19+
# Dependabot-triggered runs can't read the App secrets
920
if: github.repository == 'CSSUoB/cssuob.github.io' && github.actor != 'dependabot[bot]'
10-
permissions:
11-
pull-requests: write
12-
contents: write
1321
steps:
14-
- name: Generate Access Token
22+
- name: Generate App token
23+
id: app-token
1524
uses: actions/create-github-app-token@v3
16-
id: generate-token
1725
with:
18-
app-id: ${{ vars.PR_AUTO_UPDATE_CLIENT_ID }}
26+
client-id: ${{ vars.PR_AUTO_UPDATE_CLIENT_ID }}
1927
private-key: ${{ secrets.PR_AUTO_UPDATE_PRIVATE_KEY }}
2028

21-
- uses: CSSUoB/pr-auto-updater@v4.0.0
29+
- name: Update PRs labelled sync
30+
uses: CSSUoB/pr-auto-updater@v4.0.0
2231
env:
23-
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
24-
PR_FILTER: 'labelled'
25-
PR_LABELS: 'sync'
26-
MERGE_CONFLICT_ACTION: 'label'
27-
MERGE_CONFLICT_LABEL: 'conflict'
32+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
33+
PR_FILTER: labelled
34+
PR_LABELS: sync
35+
MERGE_CONFLICT_ACTION: label
36+
MERGE_CONFLICT_LABEL: conflict
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Static analysis
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
15+
16+
jobs:
17+
static-analysis:
18+
name: Format, lint and spellcheck
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v7
23+
with:
24+
# The parent commit is needed to work out which files changed
25+
fetch-depth: 2
26+
27+
- name: Set up Node.js
28+
uses: ./.github/actions/setup-node
29+
30+
# Each check runs even if an earlier one fails, so all problems are reported at once
31+
- name: Check formatting
32+
if: ${{ !cancelled() }}
33+
run: npm run format
34+
35+
- name: Lint JavaScript
36+
if: ${{ !cancelled() }}
37+
run: npm run lint:js
38+
39+
- name: Lint Markdown
40+
if: ${{ !cancelled() }}
41+
run: npm run lint:md
42+
43+
# Advisory only: unknown words are shown as warnings on the PR without failing the check
44+
- name: Spellcheck changed files
45+
if: ${{ !cancelled() }}
46+
continue-on-error: true
47+
run: |
48+
git diff --name-only --diff-filter=d HEAD^ HEAD -- '*.md' '*.html' \
49+
| npx cspell --file-list stdin --no-must-find-files --no-progress \
50+
--issue-template '::warning file=$filename,line=$row,col=$col::Unknown word: $text'

0 commit comments

Comments
 (0)