Skip to content

Commit 5e4ed49

Browse files
committed
Harden GitHub Actions
1 parent be62ab4 commit 5e4ed49

2 files changed

Lines changed: 40 additions & 13 deletions

File tree

.github/workflows/mkdocs.yaml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2025 Toon Verstraelen <Toon.Verstraelen@UGent.be>
1+
# SPDX-FileCopyrightText: 2024 Toon Verstraelen <Toon.Verstraelen@UGent.be>
22
# SPDX-License-Identifier: LGPL-3.0-or-later
33

44
# This workflow assumes that you deploy the documentation from the gh-pages branch.
@@ -31,21 +31,22 @@ on:
3131
- pyproject.toml
3232
- .github/workflows/mkdocs.yaml
3333

34-
permissions:
35-
contents: write
36-
3734
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
3835
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
3936
concurrency:
4037
group: pages
4138
cancel-in-progress: false
4239

4340
jobs:
44-
build:
41+
check:
42+
permissions:
43+
contents: read
4544
runs-on: ubuntu-latest
4645
steps:
4746
# Get the source
4847
- uses: actions/checkout@v6
48+
with:
49+
persist-credentials: false
4950
- uses: actions/setup-python@v6
5051
with:
5152
python-version: 3.x
@@ -54,22 +55,39 @@ jobs:
5455
with:
5556
enable-cache: true
5657
cache-dependency-glob: pyproject.toml
58+
- name: Install development version
59+
run: uv pip install --system -e .[dev]
60+
- name: Build mkdocs site
61+
run: mkdocs build --strict
5762

58-
# Prepare the environment for building docs.
59-
- name: Setup Pages
60-
id: pages
61-
uses: actions/configure-pages@v6
63+
deploy:
64+
needs: check
65+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
66+
permissions:
67+
contents: write
68+
runs-on: ubuntu-latest
69+
steps:
70+
# Get the source
71+
- uses: actions/checkout@v6
72+
- uses: actions/setup-python@v6
73+
with:
74+
python-version: 3.x
75+
- name: Set up uv
76+
uses: astral-sh/setup-uv@v8.2.0
77+
with:
78+
enable-cache: true
79+
cache-dependency-glob: pyproject.toml
6280
- name: Install development version
6381
run: uv pip install --system -e .[dev]
6482

65-
# Update the site using to the gh-pages branch with mike.
83+
# Update the site using the gh-pages branch with mike.
6684
- name: Get the docs branch
6785
run: git fetch --depth=1 origin gh-pages
6886
- name: Configure Git user for documentation commit
6987
run: |
7088
git config --global user.name 'github-actions[bot]'
7189
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
72-
- name: Build mkdocs
90+
- name: Build docs snapshot
7391
run: mike deploy dev
7492
- name: Push gh-pages branch with development version of docs
7593
if: github.ref == 'refs/heads/main'

.github/workflows/release.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2025 Toon Verstraelen <Toon.Verstraelen@UGent.be>
1+
# SPDX-FileCopyrightText: 2024 Toon Verstraelen <Toon.Verstraelen@UGent.be>
22
# SPDX-License-Identifier: LGPL-3.0-or-later
33

44
# This workflow is adapted from:
@@ -13,9 +13,12 @@ on:
1313
- 'v*'
1414
paths:
1515
# ... and only if relevant files have changed.
16-
- docs/**
16+
# This list must be consistent with MANIFEST.in.
1717
- stepup/**
1818
- pyproject.toml
19+
- LICENSE
20+
- MANIFEST.in
21+
- README.md
1922
- .github/workflows/release.yaml
2023

2124
env:
@@ -28,6 +31,9 @@ jobs:
2831
build:
2932
name: Build distribution
3033
runs-on: ubuntu-latest
34+
permissions:
35+
actions: write
36+
contents: read
3137

3238
steps:
3339
- uses: actions/checkout@v6
@@ -68,6 +74,7 @@ jobs:
6874
name: pypi
6975
url: https://pypi.org/p/${{ env.PYPI_NAME }}
7076
permissions:
77+
actions: read
7178
id-token: write
7279

7380
steps:
@@ -88,6 +95,7 @@ jobs:
8895
runs-on: ubuntu-latest
8996

9097
permissions:
98+
actions: read
9199
contents: write
92100
id-token: write
93101

@@ -139,6 +147,7 @@ jobs:
139147
url: https://test.pypi.org/p/${{ env.PYPI_NAME }}
140148

141149
permissions:
150+
actions: read
142151
id-token: write
143152

144153
steps:

0 commit comments

Comments
 (0)