Skip to content

Commit 3dd0caf

Browse files
committed
Harden GitHub Actions workflows
* Pins all 3rd party actions to digests, using digests we already use in other repositories. * Drops permissions in all workflows and explicitly declares them at the job-level where needed. * Updates release workflow to create releases as draft first, and only publish them after all assets have been uploaded. This enables us to use immutable GitHub releases. * Removes unneeded workflows. Signed-off-by: nscuro <nscuro@protonmail.com>
1 parent 307113e commit 3dd0caf

8 files changed

Lines changed: 42 additions & 102 deletions

File tree

.github/workflows/_meta-build.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
permissions: {}
2+
13
on:
24
workflow_call:
35
inputs:
@@ -27,10 +29,10 @@ jobs:
2729

2830
steps:
2931
- name: Checkout Repository
30-
uses: actions/checkout@v6.0.2
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
3133

3234
- name: Set up NodeJs
33-
uses: actions/setup-node@v6.3.0
35+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # tag=v6.3.0
3436
with:
3537
node-version: '20'
3638
cache: 'npm'
@@ -43,7 +45,7 @@ jobs:
4345
npm run build --if-present
4446
4547
- name: Upload Artifacts
46-
uses: actions/upload-artifact@v7.0.0
48+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # tag=v7.0.0
4749
with:
4850
name: assembled-frontend
4951
path: |-
@@ -57,24 +59,24 @@ jobs:
5759

5860
steps:
5961
- name: Checkout Repository
60-
uses: actions/checkout@v6.0.2
62+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
6163

6264
- name: Download Artifacts
63-
uses: actions/download-artifact@v8.0.0
65+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # tag=v8.0.0
6466
with:
6567
name: assembled-frontend
6668

6769
- name: Set up QEMU
68-
uses: docker/setup-qemu-action@v4.0.0
70+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # tag=v3.7.0
6971

7072
- name: Set up Docker Buildx
71-
uses: docker/setup-buildx-action@v4.0.0
73+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # tag=v4.0.0
7274
id: buildx
7375
with:
7476
install: true
7577

7678
- name: Login to Docker.io
77-
uses: docker/login-action@v4.0.0
79+
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # tag=v4.0.0
7880
if: ${{ inputs.publish-container }}
7981
with:
8082
registry: docker.io
@@ -99,7 +101,7 @@ jobs:
99101
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
100102
101103
- name: Build multi-arch Container Image
102-
uses: docker/build-push-action@v7.0.0
104+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # tag=v7.0.0
103105
with:
104106
tags: ${{ steps.tags.outputs.tags }}
105107
build-args: |-
@@ -109,4 +111,3 @@ jobs:
109111
push: ${{ inputs.publish-container }}
110112
context: .
111113
file: docker/Dockerfile.alpine
112-

.github/workflows/ci-build.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
- 'feature-**' # Feature branches
1212
workflow_dispatch:
1313

14+
permissions: {}
15+
1416
jobs:
1517
call-build:
1618
uses: ./.github/workflows/_meta-build.yaml

.github/workflows/ci-publish.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ name: Publish CI
33
on:
44
release:
55
types:
6-
- released
6+
- created
77
workflow_dispatch:
88

9+
permissions: {}
10+
911
jobs:
1012
read-version:
1113
runs-on: ubuntu-latest
@@ -20,7 +22,7 @@ jobs:
2022
fi
2123
2224
- name: Checkout Repository
23-
uses: actions/checkout@v6.0.2
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
2426

2527
- name: Parse Version from package.json
2628
id: parse
@@ -42,15 +44,17 @@ jobs:
4244

4345
update-github-release:
4446
runs-on: ubuntu-latest
47+
permissions:
48+
contents: write # Required to edit release.
4549
needs:
4650
- read-version
4751
- call-build
4852
steps:
4953
- name: Checkout Repository
50-
uses: actions/checkout@v6.0.2
54+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
5155

5256
- name: Download Artifacts
53-
uses: actions/download-artifact@v8.0.0
57+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # tag=v8.0.0
5458
with:
5559
name: assembled-frontend
5660

@@ -67,7 +71,7 @@ jobs:
6771
6872
- name: Update Release
6973
env:
70-
GITHUB_TOKEN: ${{ secrets.BOT_RELEASE_TOKEN }}
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7175
run: |-
7276
cat << EOF >> .github/default-release-notes.md
7377
\`\`\`text
@@ -86,3 +90,10 @@ jobs:
8690
frontend-dist.zip \
8791
checksums.txt \
8892
bom.xml bom.json
93+
94+
- name: Publish Release
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
run: |-
98+
gh release edit ${{ needs.read-version.outputs.version }} \
99+
--draft=false

.github/workflows/ci-release.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ on:
1616
- premajor
1717
- prerelease
1818

19+
permissions: {}
20+
1921
jobs:
2022
prepare-release:
2123
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write # Required to create commits.
2226
steps:
2327
- name: Checkout Repository
24-
uses: actions/checkout@v6.0.2
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
2529

2630
- name: Set up NodeJs
27-
uses: actions/setup-node@v6.3.0
31+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # tag=v6.3.0
2832
with:
2933
node-version: '20'
3034
cache: 'npm'
@@ -52,4 +56,5 @@ jobs:
5256
gh release create "${VERSION}" ${GH_OPTS} \
5357
--target "${{ github.ref_name }}" \
5458
--title "${VERSION}" \
59+
--draft \
5560
--generate-notes

.github/workflows/codeql-analysis.yaml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/dependency-review.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/i18n.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ on:
99
- 'master' # Default branch
1010
- 'feature-**' # Feature branches
1111

12-
permissions:
13-
contents: read
12+
permissions: {}
1413

1514
jobs:
1615
check:
1716
runs-on: ubuntu-latest
1817

1918
steps:
2019
- name: Checkout Repository
21-
uses: actions/checkout@v6.0.2
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
2221

2322
- name: Set up NodeJs
24-
uses: actions/setup-node@v6.3.0
23+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # tag=v6.3.0
2524
with:
2625
node-version: '20'
2726
cache: 'npm'

.github/workflows/lint.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ on:
99
- 'master' # Default branch
1010
- 'feature-**' # Feature branches
1111

12-
permissions:
13-
contents: read
12+
permissions: {}
1413

1514
jobs:
1615
lint:
1716
runs-on: ubuntu-latest
1817

1918
steps:
2019
- name: Checkout Repository
21-
uses: actions/checkout@v6.0.2
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
2221

2322
- name: Set up NodeJs
24-
uses: actions/setup-node@v6.3.0
23+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # tag=v6.3.0
2524
with:
2625
node-version: '20'
2726
cache: 'npm'

0 commit comments

Comments
 (0)