Skip to content

Commit 64edb23

Browse files
authored
CI: Harden GHA configuration (#308)
* CI: pin actions by SHA This eliminates the possibility of a tag being changed under us. * CI: pin actions by SHA This eliminates the possibility of a tag being changed under us. * CI: auto-fix via zizmor May include: - Avoids risky string interpolation. - Prevents checkout premissions from leaking * CI: Restrict default permissions Reduces risk of arbitrary code is run by attacker. * CI: run pre-commit on GHA
1 parent db2be01 commit 64edb23

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

.github/workflows/docs.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Build docs
2+
permissions:
3+
contents: read
24

35
on:
46

@@ -18,12 +20,14 @@ jobs:
1820
runs-on: ubuntu-latest
1921
steps:
2022
- uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
2125

2226
- uses: actions/setup-python@v5
2327
with:
2428
python-version: "3.10"
2529

26-
- uses: tlambert03/setup-qt-libs@v1
30+
- uses: tlambert03/setup-qt-libs@19e4ef2d781d81f5f067182e228b54ec90d23b76 # v1
2731

2832
- name: Install Dependencies
2933
run: |
@@ -32,7 +36,7 @@ jobs:
3236
sudo apt install graphviz --yes
3337
3438
- name: Build Docs
35-
uses: aganders3/headless-gui@v2
39+
uses: aganders3/headless-gui@f85dd6316993505dfc5f21839d520ae440c84816 # v2
3640
with:
3741
run: make html
3842
working-directory: ./docs
@@ -50,12 +54,14 @@ jobs:
5054
if: contains(github.ref, 'tags')
5155
steps:
5256
- uses: actions/checkout@v4
57+
with:
58+
persist-credentials: false
5359
- uses: actions/download-artifact@v4.3.0
5460
with:
5561
name: docs
5662

5763
- name: Push to GitHub pages
58-
uses: JamesIves/github-pages-deploy-action@v4
64+
uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 # v4
5965
with:
6066
folder: html
6167
ssh-key: ${{ secrets.DEPLOY_KEY }}

.github/workflows/test_and_deploy.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: tests
2+
permissions:
3+
contents: read
24

35
on:
46
push:
@@ -17,6 +19,19 @@ concurrency:
1719
cancel-in-progress: true
1820

1921
jobs:
22+
pre-commit:
23+
name: precommit
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
with:
28+
fetch-depth: 0
29+
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
30+
with:
31+
python-version: "3.x"
32+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
33+
with:
34+
extra_args: --hook-stage manual --all-files
2035
test:
2136
name: ${{ matrix.platform }} py${{ matrix.python-version }}
2237
runs-on: ${{ matrix.platform }}
@@ -28,14 +43,16 @@ jobs:
2843

2944
steps:
3045
- uses: actions/checkout@v4
46+
with:
47+
persist-credentials: false
3148

3249
- name: Set up Python ${{ matrix.python-version }}
3350
uses: actions/setup-python@v5
3451
with:
3552
python-version: ${{ matrix.python-version }}
3653

3754
# these libraries enable testing on Qt on linux
38-
- uses: tlambert03/setup-qt-libs@v1
55+
- uses: tlambert03/setup-qt-libs@19e4ef2d781d81f5f067182e228b54ec90d23b76 # v1
3956

4057
# strategy borrowed from vispy for installing opengl libs on windows
4158
- name: Install Windows OpenGL
@@ -62,7 +79,7 @@ jobs:
6279
if: ${{ always() }}
6380

6481
- name: Coverage
65-
uses: codecov/codecov-action@v5
82+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5
6683
# Don't run coverage on merge queue CI to avoid duplicating reports
6784
# to codecov. See https://github.com/matplotlib/napari-matplotlib/issues/155
6885
if: github.event_name != 'merge_group'
@@ -84,6 +101,8 @@ jobs:
84101
id-token: write
85102
steps:
86103
- uses: actions/checkout@v4
104+
with:
105+
persist-credentials: false
87106
- name: Set up Python
88107
uses: actions/setup-python@v5
89108
with:
@@ -99,4 +118,4 @@ jobs:
99118
python -m build .
100119
101120
- name: Publish package
102-
uses: pypa/gh-action-pypi-publish@release/v1
121+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

0 commit comments

Comments
 (0)