Skip to content

Commit e9f20ab

Browse files
committed
Update GH actions security
1 parent b259efb commit e9f20ab

11 files changed

Lines changed: 179 additions & 62 deletions

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 10
8+
cooldown:
9+
default-days: 7
10+
labels:
11+
- dependencies
12+
- github_actions

.github/workflows/check-pr-maintainer-access.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
name: check-pr-maintainer-access
22

3+
# pull_request_target is safe here because this workflow never checks out
4+
# the PR's code — it only reads PR metadata via GraphQL and posts a comment.
35
on:
4-
pull_request_target:
6+
pull_request_target: # zizmor: ignore[dangerous-triggers]
57
types:
68
- opened
79

810
permissions:
11+
contents: read
912
pull-requests: write
1013

1114
jobs:
1215
notify-when-maintainers-cannot-edit:
1316
runs-on: ubuntu-latest
1417
steps:
15-
- uses: actions/github-script@v3
18+
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
1619
with:
1720
script: |
1821
const query = `
@@ -48,14 +51,14 @@ jobs:
4851
if (! pullRequest.maintainerCanModify) {
4952
console.log('PR not owned by filamentphp and does not have maintainer edits enabled')
5053
51-
await github.issues.createComment({
54+
await github.rest.issues.createComment({
5255
issue_number: pullNumber,
5356
owner: 'filamentphp',
5457
repo: 'filament',
5558
body: 'Thanks for submitting a PR!\n\nIn order to review and merge PRs most efficiently, we require that all PRs grant maintainer edit access before we review them. If your fork belongs to a GitHub organization, please move the repository to your personal account and try again. If you\'re already using a personal fork, you can learn how to enable maintainer access [in the GitHub documentation](https://docs.github.com/en/github/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork).'
5659
})
5760
58-
await github.issues.update({
61+
await github.rest.issues.update({
5962
issue_number: pullNumber,
6063
owner: 'filamentphp',
6164
repo: context.repo.repo,

.github/workflows/docs-screenshots.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,54 @@ on:
44
push:
55
tags: '*'
66

7+
permissions:
8+
contents: write
9+
710
jobs:
811
take-screenshots:
912
runs-on: ubuntu-latest
1013
strategy:
1114
fail-fast: false
1215
steps:
13-
- uses: actions/checkout@v2
14-
- name: Cache dependencies
15-
uses: actions/cache@v2
16+
# persist-credentials: true is required so `git-auto-commit-action` below
17+
# can push the new screenshots. Tag-only trigger means only maintainers
18+
# invoke this workflow.
19+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked]
20+
- name: Cache Composer dependencies
21+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
1622
with:
1723
path: ~/.composer/cache/files
18-
key: dependencies-composer-${{ hashFiles('composer.json') }}
19-
- name: Setup PHP
20-
uses: shivammathur/setup-php@v2
24+
key: composer-screenshots-${{ hashFiles('docs-assets/app/composer.json') }}
25+
restore-keys: |
26+
composer-screenshots-
27+
- name: Set up PHP
28+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
2129
with:
2230
php-version: 8.3
2331
extensions: mbstring, pdo, pdo_sqlite
2432
coverage: none
25-
- name: Setup Node
26-
uses: actions/setup-node@v2
27-
- name: Install dependencies
33+
- name: Set up Node
34+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
35+
with:
36+
node-version: lts/*
37+
- name: Install screenshot dependencies
2838
run: |
2939
cd docs-assets/screenshots
30-
npm ci
31-
- name: Setup app
40+
npm ci --ignore-scripts
41+
- name: Set up app
3242
run: |
3343
cd docs-assets/app
34-
composer install --no-interaction
35-
npm ci && npm run build
44+
composer install --no-interaction --no-scripts
45+
npm ci --ignore-scripts && npm run build
3646
php artisan serve &
37-
- name: Run script
47+
- name: Take screenshots
3848
run: |
3949
cd docs-assets/screenshots
4050
node script
4151
- name: Pull changes
4252
run: git pull
4353
- name: Commit changes
44-
uses: stefanzweifel/git-auto-commit-action@v4
54+
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0
4555
with:
4656
commit_message: >
4757
chore: take docs screenshots

.github/workflows/fix-code-style.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,44 @@ name: fix-code-style
33
on:
44
push:
55

6+
permissions:
7+
contents: write
8+
69
jobs:
710
fix-code-style:
811
runs-on: ubuntu-latest
912
steps:
1013
- name: Checkout code
11-
uses: actions/checkout@v3
14+
# persist-credentials: true is required so `git-auto-commit-action` below
15+
# can push reformatted files back. Trigger is `push:`, so this only runs
16+
# on code that already reached a base-repo branch.
17+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked]
18+
- name: Cache Composer dependencies
19+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
1220
with:
13-
ref: ${{ github.head_ref }}
21+
path: ~/.composer/cache/files
22+
key: composer-cs-${{ hashFiles('composer.json') }}
23+
restore-keys: |
24+
composer-cs-
1425
- name: Set up PHP
15-
uses: shivammathur/setup-php@v2
26+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
1627
with:
1728
php-version: 8.3
1829
- name: Set up Node
19-
uses: actions/setup-node@v2
30+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
31+
with:
32+
node-version: lts/*
33+
cache: npm
2034
- name: Install dependencies
2135
run: |
22-
composer install --no-interaction
23-
npm ci
36+
composer install --no-interaction --no-scripts
37+
npm ci --ignore-scripts
2438
- name: Run Pint
2539
run: composer pint
2640
- name: Run Prettier
2741
run: npm run prettier
2842
- name: Commit changes
29-
uses: stefanzweifel/git-auto-commit-action@v4
43+
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0
3044
with:
3145
commit_message: >
3246
chore: fix code style

.github/workflows/manage-issue.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ on:
44
issues:
55
types: [opened, edited]
66

7+
permissions:
8+
contents: read
9+
issues: write
10+
711
jobs:
812
check-repro:
913
runs-on: ubuntu-latest
1014
steps:
11-
- uses: actions/github-script@v3
15+
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
1216
with:
1317
script: |
1418
const URL_REGEXP = /### Reproduction repository \(issue will be closed if this is not valid\)[\r\n]+([^#]+)###/m
@@ -51,7 +55,7 @@ jobs:
5155
.join('\n')
5256
.trim()
5357
54-
await github.issues.createComment({
58+
await github.rest.issues.createComment({
5559
issue_number: context.issue.number,
5660
owner: context.repo.owner,
5761
repo: context.repo.repo,
@@ -62,7 +66,7 @@ jobs:
6266
async function getGitHubActionComments() {
6367
debug(`Loading existing comments...`)
6468
65-
const comments = await github.issues.listComments({
69+
const comments = await github.rest.issues.listComments({
6670
issue_number: context.issue.number,
6771
owner: context.repo.owner,
6872
repo: context.repo.repo,
@@ -75,7 +79,7 @@ jobs:
7579
}
7680
7781
async function getIssueLabels() {
78-
const issues = await github.issues.listLabelsOnIssue({
82+
const issues = await github.rest.issues.listLabelsOnIssue({
7983
issue_number: context.issue.number,
8084
owner: context.repo.owner,
8185
repo: context.repo.repo,
@@ -85,7 +89,7 @@ jobs:
8589
}
8690
8791
async function updateIssue(state, state_reason = null) {
88-
await github.issues.update({
92+
await github.rest.issues.update({
8993
owner: context.repo.owner,
9094
repo: context.repo.repo,
9195
issue_number: context.issue.number,
@@ -111,7 +115,7 @@ jobs:
111115
112116
debug(`Missing required information`)
113117
114-
await github.issues.addLabels({
118+
await github.rest.issues.addLabels({
115119
issue_number: context.issue.number,
116120
owner: context.repo.owner,
117121
repo: context.repo.repo,
@@ -149,7 +153,7 @@ jobs:
149153
150154
debug(`Reopening closed issue`)
151155
152-
await github.issues.removeLabel({
156+
await github.rest.issues.removeLabel({
153157
issue_number: context.issue.number,
154158
owner: context.repo.owner,
155159
repo: context.repo.repo,

.github/workflows/monorepo-split.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
tags: '*'
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
split-monorepo:
912
runs-on: ubuntu-latest
@@ -27,11 +30,13 @@ jobs:
2730
- widgets
2831
- upgrade
2932
steps:
30-
- uses: actions/checkout@v3
33+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
with:
35+
persist-credentials: false
3136
- id: previous-tag
32-
uses: 'WyriHaximus/github-action-get-previous-tag@master'
37+
uses: WyriHaximus/github-action-get-previous-tag@61819f33034117e6c686e6a31dba995a85afc9de # v2.0.0
3338
- name: Monorepo Split of ${{ matrix.package }}
34-
uses: danharrin/monorepo-split-github-action@v2.4.0
39+
uses: danharrin/monorepo-split-github-action@f10477258c88013cc5902388ec47fe9457837041 # v2.4.4
3540
env:
3641
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
3742
with:

.github/workflows/npm-build.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,33 @@ on:
77
types:
88
- closed
99

10+
permissions:
11+
contents: write
12+
1013
jobs:
1114
npm-build:
1215
runs-on: ubuntu-latest
13-
if: github.event.pull_request.merged == true
16+
if: github.event.pull_request.merged == true && github.event.pull_request.head.repo.full_name == github.repository
1417
steps:
1518
- name: Checkout code
16-
uses: actions/checkout@v3
19+
# persist-credentials: true is required so `git-auto-commit-action` below
20+
# can push the rebuilt dist files. Same-repo-PR gate above means the
21+
# merged code came from a maintainer-authored branch.
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked]
1723
with:
1824
ref: 3.x
19-
- name: Setup Node
20-
uses: actions/setup-node@v2
25+
- name: Set up Node
26+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
27+
with:
28+
node-version: lts/*
2129
- name: Install dependencies
22-
run: npm ci
30+
run: npm ci --ignore-scripts
2331
- name: Build assets
2432
run: npm run build
2533
- name: Pull changes
2634
run: git pull
2735
- name: Commit changes
28-
uses: stefanzweifel/git-auto-commit-action@v4
36+
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0
2937
with:
3038
branch: 3.x
3139
commit_message: >

.github/workflows/phpstan.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ on:
44
push:
55
pull_request:
66

7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
714
jobs:
815
phpstan:
916
runs-on: ubuntu-latest
@@ -22,14 +29,19 @@ jobs:
2229
testbench: 8.*
2330
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
2431
steps:
25-
- uses: actions/checkout@v3
26-
- name: Cache dependencies
27-
uses: actions/cache@v3
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
persist-credentials: false
35+
- name: Cache Composer dependencies
36+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
2837
with:
2938
path: ~/.composer/cache/files
30-
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
31-
- name: Setup PHP
32-
uses: shivammathur/setup-php@v2
39+
key: composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ hashFiles('composer.json') }}
40+
restore-keys: |
41+
composer-${{ matrix.php }}-${{ matrix.laravel }}-
42+
composer-${{ matrix.php }}-
43+
- name: Set up PHP
44+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
3345
with:
3446
php-version: ${{ matrix.php }}
3547
extensions: mbstring, pdo, pdo_sqlite

.github/workflows/tests.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ on:
44
push:
55
pull_request:
66

7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
714
jobs:
815
run-tests:
916
runs-on: ubuntu-latest
@@ -22,14 +29,19 @@ jobs:
2229
testbench: 8.*
2330
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
2431
steps:
25-
- uses: actions/checkout@v3
26-
- name: Cache dependencies
27-
uses: actions/cache@v3
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
persist-credentials: false
35+
- name: Cache Composer dependencies
36+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
2837
with:
2938
path: ~/.composer/cache/files
30-
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
31-
- name: Setup PHP
32-
uses: shivammathur/setup-php@v2
39+
key: composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ hashFiles('composer.json') }}
40+
restore-keys: |
41+
composer-${{ matrix.php }}-${{ matrix.laravel }}-
42+
composer-${{ matrix.php }}-
43+
- name: Set up PHP
44+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
3345
with:
3446
php-version: ${{ matrix.php }}
3547
extensions: mbstring, pdo, pdo_sqlite

0 commit comments

Comments
 (0)