Skip to content

Commit bee2974

Browse files
authored
chore(ci): harden workflow by setting default permission to read only (#728)
In `sync.yml` `contents: write` permissions are required to push perform the sync as well as persist credentials (explicitly marked at true). `persist-credentials: true` is required in order to push to the `v1` branch by the workflow
1 parent 11ba61d commit bee2974

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: CI
22

3+
permissions:
4+
contents: read
5+
36
on:
47
workflow_dispatch:
58
pull_request:
@@ -27,7 +30,9 @@ jobs:
2730
- --use solc:0.6.2
2831
- --use solc:0.6.12
2932
steps:
30-
- uses: actions/checkout@v4
33+
- uses: actions/checkout@v5
34+
with:
35+
persist-credentials: false
3136
- uses: foundry-rs/foundry-toolchain@v1
3237
- run: forge --version
3338
- run: |
@@ -51,7 +56,9 @@ jobs:
5156
matrix:
5257
toolchain: [stable, nightly]
5358
steps:
54-
- uses: actions/checkout@v4
59+
- uses: actions/checkout@v5
60+
with:
61+
persist-credentials: false
5562
- uses: foundry-rs/foundry-toolchain@v1
5663
with:
5764
version: ${{ matrix.toolchain }}
@@ -67,7 +74,9 @@ jobs:
6774
runs-on: ubuntu-latest
6875
timeout-minutes: 10
6976
steps:
70-
- uses: actions/checkout@v4
77+
- uses: actions/checkout@v5
78+
with:
79+
persist-credentials: false
7180
- uses: foundry-rs/foundry-toolchain@v1
7281
- run: forge --version
7382
- run: forge fmt --check
@@ -76,12 +85,15 @@ jobs:
7685
runs-on: ubuntu-latest
7786
timeout-minutes: 10
7887
steps:
79-
- uses: actions/checkout@v4
88+
- uses: actions/checkout@v5
89+
with:
90+
persist-credentials: false
8091
- uses: crate-ci/typos@v1
8192

8293
ci-success:
8394
runs-on: ubuntu-latest
8495
if: always()
96+
permissions: {}
8597
needs:
8698
- build
8799
- test

.github/workflows/sync.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Sync Release Branch
22

3+
permissions:
4+
contents: read
5+
36
on:
47
release:
58
types:
@@ -8,11 +11,14 @@ on:
811
jobs:
912
sync-release-branch:
1013
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
1116
if: startsWith(github.event.release.tag_name, 'v1')
1217
steps:
1318
- name: Check out the repo
14-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
1520
with:
21+
persist-credentials: true
1622
fetch-depth: 0
1723
ref: v1
1824

0 commit comments

Comments
 (0)