Skip to content

Commit b0b8a94

Browse files
chore: pin GitHub Actions to commit SHAs (#130)
* chore: pin actions to SHA in .github/workflows/audit.yml * chore: pin actions to SHA in .github/workflows/deny.yml * chore: pin actions to SHA in .github/workflows/fmt.yml * chore: pin actions to SHA in .github/workflows/lint.yml * chore: pin actions to SHA in .github/workflows/prepare-release.yml * chore: pin actions to SHA in .github/workflows/release.yml * chore: pin actions to SHA in .github/workflows/test.yml * fix: Pin GitHub Actions to exact commit SHAs in the generated release.yml (required by security policy) --------- Co-authored-by: Linwei Shang <linwei.shang@dfinity.org>
1 parent 61c84aa commit b0b8a94

8 files changed

Lines changed: 33 additions & 27 deletions

File tree

.github/workflows/audit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
issues: write
2929

3030
steps:
31-
- uses: actions/checkout@v4
32-
- uses: actions-rust-lang/audit@v1
31+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
32+
- uses: actions-rust-lang/audit@72c09e02f132669d52284a3323acdb503cfc1a24 # v1.2.7

.github/workflows/deny.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: license-check:required
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v4
25-
- uses: EmbarkStudios/cargo-deny-action@v2
24+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
25+
- uses: EmbarkStudios/cargo-deny-action@3fd3802e88374d3fe9159b834c7714ec57d6c979 # v2.0.15
2626
with:
2727
command: check bans licenses sources # skip advisories, which are handled by audit.yml

.github/workflows/fmt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
1616

1717
- name: Run Cargo Fmt
1818
run: cargo fmt --all -- --check

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
1616

1717
- name: Cache Cargo
18-
uses: actions/cache@v4
18+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
1919
with:
2020
path: |
2121
~/.cargo/registry

.github/workflows/prepare-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
prepare-release:
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
2828
with:
2929
fetch-depth: 0
3030

3131
- name: Use Rust version from rust-toolchain.toml
3232
run: rustup show
3333

34-
- uses: cargo-bins/cargo-binstall@main
34+
- uses: cargo-bins/cargo-binstall@6ed12bbaae779f3fd3ba1477bc9a61a2535a3bb2 # main
3535

3636
- name: Install dependencies
3737
run: cargo binstall cargo-release -y

.github/workflows/release.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
env:
5757
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5858
steps:
59-
- uses: actions/checkout@v6
59+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
6060
with:
6161
persist-credentials: false
6262
submodules: recursive
@@ -66,7 +66,7 @@ jobs:
6666
shell: bash
6767
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.31.0/cargo-dist-installer.sh | sh"
6868
- name: Cache dist
69-
uses: actions/upload-artifact@v6
69+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
7070
with:
7171
name: cargo-dist-cache
7272
path: ~/.cargo/bin/dist
@@ -82,7 +82,7 @@ jobs:
8282
cat plan-dist-manifest.json
8383
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
8484
- name: "Upload dist-manifest.json"
85-
uses: actions/upload-artifact@v6
85+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
8686
with:
8787
name: artifacts-plan-dist-manifest
8888
path: plan-dist-manifest.json
@@ -116,7 +116,7 @@ jobs:
116116
- name: enable windows longpaths
117117
run: |
118118
git config --global core.longpaths true
119-
- uses: actions/checkout@v6
119+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
120120
with:
121121
persist-credentials: false
122122
submodules: recursive
@@ -131,7 +131,7 @@ jobs:
131131
run: ${{ matrix.install_dist.run }}
132132
# Get the dist-manifest
133133
- name: Fetch local artifacts
134-
uses: actions/download-artifact@v7
134+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
135135
with:
136136
pattern: artifacts-*
137137
path: target/distrib/
@@ -158,7 +158,7 @@ jobs:
158158
159159
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
160160
- name: "Upload artifacts"
161-
uses: actions/upload-artifact@v6
161+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
162162
with:
163163
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
164164
path: |
@@ -175,19 +175,19 @@ jobs:
175175
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176176
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
177177
steps:
178-
- uses: actions/checkout@v6
178+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
179179
with:
180180
persist-credentials: false
181181
submodules: recursive
182182
- name: Install cached dist
183-
uses: actions/download-artifact@v7
183+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
184184
with:
185185
name: cargo-dist-cache
186186
path: ~/.cargo/bin/
187187
- run: chmod +x ~/.cargo/bin/dist
188188
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
189189
- name: Fetch local artifacts
190-
uses: actions/download-artifact@v7
190+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
191191
with:
192192
pattern: artifacts-*
193193
path: target/distrib/
@@ -205,7 +205,7 @@ jobs:
205205
206206
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
207207
- name: "Upload artifacts"
208-
uses: actions/upload-artifact@v6
208+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
209209
with:
210210
name: artifacts-build-global
211211
path: |
@@ -225,19 +225,19 @@ jobs:
225225
outputs:
226226
val: ${{ steps.host.outputs.manifest }}
227227
steps:
228-
- uses: actions/checkout@v6
228+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
229229
with:
230230
persist-credentials: false
231231
submodules: recursive
232232
- name: Install cached dist
233-
uses: actions/download-artifact@v7
233+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
234234
with:
235235
name: cargo-dist-cache
236236
path: ~/.cargo/bin/
237237
- run: chmod +x ~/.cargo/bin/dist
238238
# Fetch artifacts from scratch-storage
239239
- name: Fetch artifacts
240-
uses: actions/download-artifact@v7
240+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
241241
with:
242242
pattern: artifacts-*
243243
path: target/distrib/
@@ -250,14 +250,14 @@ jobs:
250250
cat dist-manifest.json
251251
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
252252
- name: "Upload dist-manifest.json"
253-
uses: actions/upload-artifact@v6
253+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
254254
with:
255255
# Overwrite the previous copy
256256
name: artifacts-dist-manifest
257257
path: dist-manifest.json
258258
# Create a GitHub Release while uploading all files to it
259259
- name: "Download GitHub Artifacts"
260-
uses: actions/download-artifact@v7
260+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
261261
with:
262262
pattern: artifacts-*
263263
path: artifacts
@@ -290,7 +290,7 @@ jobs:
290290
env:
291291
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
292292
steps:
293-
- uses: actions/checkout@v6
293+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
294294
with:
295295
persist-credentials: false
296296
submodules: recursive

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
matrix:
1616
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15, macos-15-intel]
1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
1919

20-
- uses: actions/cache@v4
20+
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
2121
with:
2222
path: |
2323
~/.cargo/registry

dist-workspace.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ unix-archive = ".tar.gz"
1818
# Whether to consider the binaries in a package for distribution (defaults true)
1919
dist = true
2020

21+
# Pin GitHub Actions to exact commit SHAs in the generated release.yml (required by security policy)
22+
[dist.github-action-commits]
23+
"actions/checkout" = "de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
24+
"actions/upload-artifact" = "b7c566a772e6b6bfb58ed0dc250532a479d7789f" # v6.0.0
25+
"actions/download-artifact" = "37930b1c2abaa49bbe596cd826c3c89aef350131" # v7.0.0
26+
2127
[dist.github-custom-runners]
2228
global = "ubuntu-22.04"
2329
x86_64-unknown-linux-gnu = "ubuntu-22.04"

0 commit comments

Comments
 (0)