Skip to content

Commit aa0466c

Browse files
peaceiriscodex
andauthored
ci: harden GitHub Actions workflows (#1156)
Co-authored-by: Codex <noreply@openai.com>
1 parent 31835fb commit aa0466c

10 files changed

Lines changed: 63 additions & 45 deletions

.github/labeler.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
cicd:
22
- changed-files:
3-
- any-glob-to-any-file: .github/workflows/*
3+
- any-glob-to-any-file: '.github/workflows/*'
44

55
dependencies:
66
- changed-files:
77
- any-glob-to-any-file:
8-
- .nvmrc
9-
- package.json
10-
- package-lock.json
8+
- '.nvmrc'
9+
- 'package.json'
10+
- 'package-lock.json'
1111

1212
documentation:
1313
- changed-files:
14-
- any-glob-to-any-file: README.md
14+
- any-glob-to-any-file: 'README.md'
1515

1616
test:
1717
- changed-files:
18-
- any-glob-to-any-file: __tests__
18+
- any-glob-to-any-file: '__tests__/**'
1919

2020
docker:
2121
- changed-files:
2222
- any-glob-to-any-file:
23-
- .devcontainer/*
24-
- .dockerignore
25-
- Dockerfile
26-
- Makefile
27-
- docker-compose.yml
23+
- '.devcontainer/*'
24+
- '.dockerignore'
25+
- 'Dockerfile'
26+
- 'Makefile'
27+
- 'docker-compose.yml'

.github/workflows/codeql.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@ on:
66
- main
77
pull_request:
88

9+
permissions:
10+
actions: read
11+
contents: read
12+
packages: read
13+
security-events: write
14+
915
jobs:
1016
CodeQL-Build:
1117
runs-on: ubuntu-24.04
18+
timeout-minutes: 20
1219
steps:
13-
- uses: actions/checkout@v6
20+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1421

1522
- name: Initialize CodeQL
16-
uses: github/codeql-action/init@v4
23+
uses: github/codeql-action/init@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4.35.4
1724
with:
1825
languages: javascript
1926

2027
- name: Autobuild
21-
uses: github/codeql-action/autobuild@v4
28+
uses: github/codeql-action/autobuild@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4.35.4
2229

2330
- name: Perform CodeQL Analysis
24-
uses: github/codeql-action/analyze@v4
31+
uses: github/codeql-action/analyze@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4.35.4

.github/workflows/dependency-review.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ permissions:
1010

1111
jobs:
1212
dependency-review:
13-
runs-on: ubuntu-24.04
13+
runs-on: ubuntu-slim
14+
timeout-minutes: 5
1415
steps:
15-
- uses: actions/checkout@v6
16-
- uses: actions/dependency-review-action@v5.0.0
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
- uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0

.github/workflows/label-commenter.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ permissions:
1717

1818
jobs:
1919
comment:
20-
runs-on: ubuntu-24.04
20+
runs-on: ubuntu-slim
21+
timeout-minutes: 5
2122
steps:
22-
- uses: actions/checkout@v6
23+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2324

2425
- name: Label Commenter
25-
uses: peaceiris/actions-label-commenter@v1
26+
uses: peaceiris/actions-label-commenter@f0dbbef043eb1b150b566db36b0bdc8b7f505579 # v1.10.0
2627
env:
2728
RUNNER_DEBUG: 1

.github/workflows/labeler.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ on:
55

66
jobs:
77
triage:
8-
runs-on: ubuntu-24.04
9-
timeout-minutes: 1
8+
runs-on: ubuntu-slim
9+
timeout-minutes: 5
1010
permissions: {}
1111
steps:
1212
# https://github.com/peaceiris/actions-github-app-token
13-
- uses: peaceiris/actions-github-app-token@v1.1.6
13+
- uses: peaceiris/actions-github-app-token@652b86006ad2c113bdd5c478c9a98f359829847b # v1.1.6
1414
id: app
1515
with:
1616
app_id: ${{ secrets.GH_APP_ID }}
1717
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
1818

1919
# https://github.com/actions/labeler
20-
- uses: actions/labeler@v6
20+
- uses: actions/labeler@f27b608878404679385c85cfa523b85ccb86e213 # v6.1.0
2121
with:
2222
repo-token: "${{ steps.app.outputs.token }}"

.github/workflows/pages-status-check.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on: page_build
44

55
jobs:
66
pages-status-check:
7-
runs-on: ubuntu-24.04
7+
runs-on: ubuntu-slim
8+
timeout-minutes: 5
9+
permissions: {}
810
steps:
911
- name: check status
1012
run: |

.github/workflows/purge-readme-image-cache.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ on:
88
jobs:
99
purge:
1010
runs-on: ubuntu-24.04
11+
timeout-minutes: 5
12+
permissions: {}
1113
steps:
12-
13-
- run: >
14-
curl -sL https://github.com/${GITHUB_REPOSITORY} |
15-
grep -oE '<img src="https?://camo.githubusercontent.com/[^"]+' |
16-
sed -e 's/<img src="//' |
17-
xargs -I % curl -sX PURGE %
14+
- run: >
15+
curl -sL "https://github.com/${GITHUB_REPOSITORY}" |
16+
grep -oE '<img src="https?://camo.githubusercontent.com/[^"]+' |
17+
sed -e 's/<img src="//' |
18+
xargs -I % curl -sX PURGE "%"

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ on:
88
jobs:
99
release:
1010
runs-on: ubuntu-24.04
11+
timeout-minutes: 10
12+
permissions:
13+
contents: write
1114
steps:
12-
- uses: actions/checkout@v6
15+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1316
# https://github.com/peaceiris/workflows/blob/main/create-release-npm/action.yml
14-
- uses: peaceiris/workflows/create-release-npm@v0.21.6
17+
- uses: peaceiris/workflows/create-release-npm@99f66a30a38f806fd0df9014275c7cef0b6d9ca5 # v0.21.6
1518
env:
1619
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ concurrency:
1717
jobs:
1818
test:
1919
runs-on: ${{ matrix.os }}
20+
timeout-minutes: 30
2021
strategy:
2122
matrix:
2223
os:
@@ -28,9 +29,9 @@ jobs:
2829
permissions:
2930
contents: write
3031
steps:
31-
- uses: actions/checkout@v6
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3233

33-
- uses: actions/setup-node@v6
34+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
3435
with:
3536
node-version-file: ".nvmrc"
3637
cache: 'npm'
@@ -44,7 +45,7 @@ jobs:
4445
- run: npm ci --ignore-scripts
4546

4647
- name: npm audit
47-
if: startsWith(matrix.os, 'ubuntu-22.04')
48+
if: startsWith(matrix.os, 'ubuntu-24.04')
4849
run: |
4950
npm audit > ./audit.log || true
5051
if ! [ "$(cat ./audit.log | wc -l)" = 1 ]; then
@@ -53,22 +54,22 @@ jobs:
5354
rm ./audit.log
5455
5556
- name: Run prettier
56-
if: startsWith(matrix.os, 'ubuntu-22.04')
57+
if: startsWith(matrix.os, 'ubuntu-24.04')
5758
run: npm run format:check
5859

5960
- name: Run eslint
60-
if: startsWith(matrix.os, 'ubuntu-22.04')
61+
if: startsWith(matrix.os, 'ubuntu-24.04')
6162
run: npm run lint
6263

6364
- run: npm test
6465

6566
- name: Upload test coverage as artifact
66-
uses: actions/upload-artifact@v7
67+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
6768
with:
6869
name: coverage-${{ matrix.os }}
6970
path: coverage
7071

71-
- uses: codecov/codecov-action@v4
72+
- uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
7273

7374
- name: Run build
7475
run: npm run build
@@ -81,7 +82,7 @@ jobs:
8182
8283
- name: Setup mdBook
8384
if: ${{ github.ref == 'refs/heads/main' }}
84-
uses: peaceiris/actions-mdbook@v2.0.0
85+
uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08 # v2.0.0
8586
with:
8687
mdbook-version: '0.4.5'
8788

.github/workflows/update-major-tag.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ on:
66

77
jobs:
88
update:
9-
runs-on: ubuntu-24.04
10-
timeout-minutes: 1
9+
runs-on: ubuntu-slim
10+
timeout-minutes: 5
11+
permissions:
12+
contents: write
1113
steps:
12-
- uses: actions/checkout@v6
14+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1315

1416
- name: Update major tag
1517
run: |

0 commit comments

Comments
 (0)