Skip to content

Commit d8c9c71

Browse files
committed
Secure GitHub Actions workflows
Signed-off-by: Joey@macstudio <johuang@aligntech.com>
1 parent ad550bd commit d8c9c71

3 files changed

Lines changed: 50 additions & 13 deletions

File tree

.github/workflows/build.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
# At 12:00 UTC on every day-of-month
1010
- cron: "0 12 */1 * *"
1111

12+
permissions:
13+
contents: read
14+
1215
concurrency:
1316
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1417
cancel-in-progress: true
@@ -31,14 +34,16 @@ jobs:
3134
- { "py": "3.8", "tox_env": "py38" }
3235
steps:
3336
- name: setup python for tox
34-
uses: actions/setup-python@v6.3.0
37+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
3538
with:
3639
python-version: "3.11"
3740
- name: install tox
3841
run: python -m pip install tox
39-
- uses: actions/checkout@v7.0.0
42+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
43+
with:
44+
persist-credentials: false
4045
- name: setup python for test ${{ matrix.py }}
41-
uses: actions/setup-python@v6.3.0
46+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
4247
with:
4348
python-version: ${{ matrix.py }}-dev
4449
- name: setup test suite ${{ matrix.tox_env }}
@@ -50,9 +55,11 @@ jobs:
5055
name: check docs
5156
runs-on: ubuntu-22.04
5257
steps:
53-
- uses: actions/checkout@v7.0.0
58+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
59+
with:
60+
persist-credentials: false
5461
- name: setup Python 3.14
55-
uses: actions/setup-python@v6.3.0
62+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
5663
with:
5764
python-version: "3.14"
5865
- name: install tox
@@ -66,14 +73,14 @@ jobs:
6673
name: lint
6774
runs-on: ubuntu-22.04
6875
steps:
69-
- uses: actions/checkout@v7.0.0
76+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
77+
with:
78+
persist-credentials: false
7079
# mypy needs to be run with the oldest Python version we support.
7180
- name: setup Python 3.8
72-
uses: actions/setup-python@v6.3.0
81+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
7382
with:
7483
python-version: "3.8"
75-
- name: Install prettier
76-
run: npm install -g prettier
7784
- name: install tox
7885
run: python -m pip install tox
7986
- name: install lint dependencies

.github/workflows/build_dist.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
# At 12:00 UTC on every day-of-month
1111
- cron: "0 12 */1 * *"
1212

13+
permissions:
14+
contents: read
15+
1316
concurrency:
1417
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1518
cancel-in-progress: true
@@ -19,12 +22,14 @@ jobs:
1922
name: Source and wheel distributions
2023
runs-on: ubuntu-latest
2124
steps:
22-
- uses: actions/checkout@v7.0.0
25+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
26+
with:
27+
persist-credentials: false
2328

2429
- name: Build distributions
2530
run: pipx run build[virtualenv] --sdist --wheel
2631

27-
- uses: actions/upload-artifact@v7
32+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
2833
with:
2934
path: dist/*
3035

@@ -35,9 +40,9 @@ jobs:
3540
permissions:
3641
id-token: write # Required to retrieve a Trusted Publishing token
3742
steps:
38-
- uses: actions/download-artifact@v8
43+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
3944
with:
4045
name: artifact
4146
path: dist
4247

43-
- uses: pypa/gh-action-pypi-publish@v1.14.0
48+
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0

.github/workflows/zizmor.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: GitHub Actions Security Analysis with zizmor
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
permissions: {}
10+
11+
jobs:
12+
zizmor:
13+
name: Run zizmor
14+
runs-on: ubuntu-latest
15+
permissions:
16+
security-events: write
17+
contents: read
18+
actions: read
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
22+
with:
23+
persist-credentials: false
24+
- name: Run zizmor
25+
uses: zizmorcore/zizmor-action@192e21d79ab29983730a13d1382995c2307fbcaa # v0.5.7

0 commit comments

Comments
 (0)