Skip to content

Commit fd10a6b

Browse files
committed
chore: refine gh workflows for security and consistency
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 5ab81b9 commit fd10a6b

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

.github/workflows/create-github-release.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ jobs:
1313
contents: write # needed to create releases and upload assets
1414

1515
steps:
16-
- name: Create a GitHub release
17-
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
16+
- name: Checkout repository
17+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1818
with:
19-
generate_release_notes: true
20-
draft: false
21-
files: dist/*
19+
persist-credentials: false
20+
21+
- name: Create a GitHub release
22+
run: gh release create "$GITHUB_REF_NAME" --generate-notes
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr-quality.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ permissions:
66
pull-requests: write
77

88
on:
9+
# pull_request_target is required so the action can close/comment on fork PRs.
10+
# This is safe because: no untrusted code is checked out, and no attacker-controlled
11+
# values are interpolated into shell commands. All action inputs are hardcoded.
912
pull_request_target:
1013
types: [opened, reopened]
1114

.github/workflows/publish-docker-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
push: true
6565
tags: |
6666
${{ steps.meta.outputs.tags }}
67-
${{ env.REGISTRY }}/aboutcode-org/dejacode:latest
67+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
6868
labels: ${{ steps.meta.outputs.labels }}
6969

7070
# This step generates an artifact attestation for the image, which is an

.github/workflows/publish-pypi-release-aboutcode-api-auth.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
tags:
77
- "aboutcode.api_auth/*"
88

9+
env:
10+
PYPI_PROJECT_URL: "https://pypi.org/p/aboutcode.api_auth"
11+
PYPROJECT_TOML: "api_auth-pyproject.toml"
12+
FLOT_VERSION: "0.7.2"
13+
914
jobs:
1015
build:
1116
name: Build and publish library to PyPI
@@ -24,10 +29,10 @@ jobs:
2429
python-version: 3.14
2530

2631
- name: Install flot
27-
run: python -m pip install flot --user
32+
run: python -m pip install "flot==${FLOT_VERSION}" --user
2833

2934
- name: Build a binary wheel and a source tarball
30-
run: python -m flot --pyproject api_auth-pyproject.toml --sdist --wheel --output-dir dist/
35+
run: python -m flot --pyproject "$PYPROJECT_TOML" --sdist --wheel --output-dir dist/
3136

3237
- name: Upload package distributions as GitHub workflow artifacts
3338
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
@@ -36,7 +41,7 @@ jobs:
3641
path: dist/
3742

3843
# Only set the id-token: write permission in the job that does publishing, not globally.
39-
# Also, separate building from publishing this makes sure that any scripts
44+
# Also, separate building from publishing, this makes sure that any scripts
4045
# maliciously injected into the build or test environment won't be able to elevate
4146
# privileges while flying under the radar.
4247
pypi-publish:
@@ -47,7 +52,7 @@ jobs:
4752
runs-on: ubuntu-24.04
4853
environment:
4954
name: pypi
50-
url: https://pypi.org/p/aboutcode.api_auth
55+
url: ${{ env.PYPI_PROJECT_URL }}
5156
permissions:
5257
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
5358

0 commit comments

Comments
 (0)