Skip to content

Commit c556dd3

Browse files
committed
Pin GitHub Actions to commit hashes and harden things
1 parent 39eb42e commit c556dd3

5 files changed

Lines changed: 67 additions & 19 deletions

File tree

.github/workflows/nightly-tests.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ on:
66

77
workflow_dispatch:
88

9-
permissions:
10-
contents: read
9+
permissions: {}
1110

1211
jobs:
1312
nightly-test:
1413
# Cannot check the existence of secrets, so limiting to repository name to prevent all forks to run nightly.
1514
# See: https://github.com/actions/runner/issues/520
1615
if: ${{ github.repository == 'torchbox/wagtailmedia' }}
1716
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
1819

1920
services:
2021
postgres:
@@ -26,13 +27,13 @@ jobs:
2627
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
2728

2829
steps:
29-
- uses: actions/checkout@v5
30+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3031
with:
3132
persist-credentials: false
3233
- name: Set up Python
33-
uses: actions/setup-python@v6
34+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3435
with:
35-
python-version: "3.13"
36+
python-version: "3.14"
3637
- name: Install dependencies
3738
run: |
3839
python -m pip install --upgrade pip

.github/workflows/publish.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ on:
44
release:
55
types: [published]
66

7+
permissions: {}
8+
79
jobs:
810
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
911
release:
1012
runs-on: ubuntu-latest
13+
if: github.repository_owner == 'torchbox' && github.event.action == 'published'
1114
environment:
1215
name: 'release'
1316
url: https://pypi.org/p/wagtailmedia
@@ -32,14 +35,14 @@ jobs:
3235
rekor.sigstore.dev:443
3336
tuf-repo-cdn.sigstore.dev:443
3437
35-
- uses: actions/checkout@v5
38+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3639
with:
3740
persist-credentials: false
3841
fetch-depth: 0
3942

40-
- uses: actions/setup-python@v6
43+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
4144
with:
42-
python-version: '3.13'
45+
python-version: '3.14'
4346
cache: "pip"
4447
cache-dependency-path: "**/pyproject.toml"
4548

@@ -51,4 +54,4 @@ jobs:
5154
run: python -Im flit build
5255

5356
- name: 🚀 Publish package distributions to PyPI
54-
uses: pypa/gh-action-pypi-publish@release/v1
57+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0

.github/workflows/ruff.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,28 @@ on:
88
pull_request:
99
branches: [main]
1010

11-
permissions:
12-
contents: read
11+
permissions: {}
1312

1413
jobs:
1514
ruff:
1615
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
1718

1819
steps:
19-
- uses: actions/checkout@v5
20+
- name: Harden Runner
21+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
22+
with:
23+
disable-sudo: true
24+
egress-policy: block
25+
allowed-endpoints: >
26+
files.pythonhosted.org:443
27+
objects.githubusercontent.com:443
28+
github.com:443
29+
pypi.org:443
30+
api.github.com:443
31+
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2033
with:
2134
persist-credentials: false
2235

.github/workflows/test.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ jobs:
4242
github.com:443
4343
pypi.org:443
4444
api.github.com:443
45-
- uses: actions/checkout@v5
45+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4646
with:
4747
persist-credentials: false
4848
- name: 🐍 Set up Python ${{ matrix.python-version }}
49-
uses: actions/setup-python@v6
49+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
5050
with:
5151
python-version: ${{ matrix.python-version }}
5252

@@ -62,7 +62,7 @@ jobs:
6262
run: tox --installpkg ./dist/*.whl
6363

6464
- name: ⬆️ Upload coverage data
65-
uses: actions/upload-artifact@v5
65+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
6666
with:
6767
name: coverage-data-${{ matrix.python-version }}
6868
path: .coverage.*
@@ -85,19 +85,19 @@ jobs:
8585
github.com:443
8686
pypi.org:443
8787
api.github.com:443
88-
- uses: actions/checkout@v5
88+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
8989
with:
9090
persist-credentials: false
9191
fetch-depth: 0
92-
- uses: actions/setup-python@v5
92+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
9393
with:
9494
# Use latest Python, so it understands all syntax.
9595
python-version: ${{env.PYTHON_LATEST}}
9696

9797
- run: python -Im pip install --upgrade coverage
9898

9999
- name: Download coverage data
100-
uses: actions/download-artifact@v5
100+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
101101
with:
102102
pattern: coverage-data-*
103103
merge-multiple: true
@@ -110,7 +110,7 @@ jobs:
110110
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
111111
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
112112
- name: 📈 Upload HTML report if check failed.
113-
uses: actions/upload-artifact@v5
113+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
114114
with:
115115
name: html-report
116116
path: htmlcov

.github/workflows/zizmore.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# https://github.com/woodruffw/zizmor
2+
name: Zizmor 🌈
3+
4+
on:
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
branches: ["**"]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions: {}
15+
16+
jobs:
17+
zizmor:
18+
name: Run zizmor 🌈
19+
runs-on: ubuntu-latest
20+
permissions:
21+
security-events: write # Required for upload-sarif (used by zizmor-action) to upload SARIF files.
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
persist-credentials: false
27+
28+
- name: Run zizmor 🌈
29+
uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
30+
with:
31+
persona: pedantic

0 commit comments

Comments
 (0)