Skip to content

Commit 142b99e

Browse files
[TASK] Harden GitHub Actions
1 parent 0133090 commit 142b99e

3 files changed

Lines changed: 39 additions & 19 deletions

File tree

.github/workflows/cgl.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
branches:
88
- main
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
prepare:
1215
name: Prepare workflow
@@ -16,10 +19,12 @@ jobs:
1619
runs-on: ubuntu-latest
1720
needs: prepare
1821
if: needs.prepare.outputs.continue == 'true'
22+
permissions:
23+
security-events: write
1924
steps:
2025
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2126
with:
22-
fetch-depth: 0
27+
persist-credentials: false
2328

2429
# Prepare environment
2530
- name: Setup PHP
@@ -76,3 +81,7 @@ jobs:
7681
# Migration
7782
- name: Run Rector migration
7883
run: composer migration:rector -- --dry-run
84+
85+
# Zizmor
86+
- name: Run zizmor
87+
uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6

.github/workflows/release.yaml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ on:
55
- '*'
66
workflow_dispatch:
77

8+
env:
9+
REF_NAME: ${{ github.ref_name }}
10+
811
jobs:
912
phar:
1013
name: Compile PHAR
1114
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
1217
steps:
1318
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1419
with:
15-
fetch-depth: 0
20+
persist-credentials: false
1621

1722
# Prepare environment
1823
- name: Setup PHP
@@ -28,6 +33,7 @@ jobs:
2833
uses: ramsey/composer-install@5c2bcf28d7b060ef3c601d7b476d5430a7b46c27 #v4
2934
with:
3035
composer-options: "--no-dev"
36+
ignore-cache: true
3137
- name: Compile PHAR
3238
run: ./tools/box compile --with-docker
3339

@@ -54,16 +60,19 @@ jobs:
5460
name: Docker deploy
5561
runs-on: ubuntu-latest
5662
needs: phar
63+
permissions:
64+
contents: read
65+
packages: write
5766
steps:
5867
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
5968
with:
60-
fetch-depth: 0
69+
persist-credentials: false
6170

6271
# Check if tag is valid
6372
- name: Check tag
6473
if: ${{ github.event_name != 'workflow_dispatch' }}
6574
run: |
66-
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
75+
if ! [[ "$REF_NAME" =~ ^\d+\.\d+\.\d+$ ]]; then
6776
exit 1
6877
fi
6978
@@ -86,7 +95,7 @@ jobs:
8695
tags: |
8796
type=raw,value=latest,enable=${{ github.event_name != 'workflow_dispatch' }}
8897
type=semver,pattern={{version}}
89-
type=raw,value=${{ github.ref_name }},enable=${{ github.event_name == 'workflow_dispatch' }}
98+
type=raw,value=${{ env.REF_NAME }},enable=${{ github.event_name == 'workflow_dispatch' }}
9099
91100
# Prepare build
92101
- name: Set up QEMU
@@ -126,8 +135,6 @@ jobs:
126135
environment:
127136
name: github-pages
128137
url: ${{ steps.deployment.outputs.page_url }}
129-
130-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
131138
permissions:
132139
contents: read
133140
pages: write
@@ -141,14 +148,14 @@ jobs:
141148
steps:
142149
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
143150
with:
144-
fetch-depth: 0
151+
persist-credentials: false
145152

146153
# Prepare environment
147154
- name: Setup Node
148155
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
149156
with:
150157
node-version: 24
151-
cache: npm
158+
package-manager-cache: false
152159
- name: Setup PHP
153160
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
154161
with:
@@ -201,15 +208,17 @@ jobs:
201208
if: ${{ github.event_name != 'workflow_dispatch' }}
202209
runs-on: ubuntu-latest
203210
needs: phar
211+
permissions:
212+
contents: write
204213
steps:
205214
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
206215
with:
207-
fetch-depth: 0
216+
persist-credentials: false
208217

209218
# Check if tag is valid
210219
- name: Check tag
211220
run: |
212-
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
221+
if ! [[ "${REF_NAME}" =~ ^\d+\.\d+\.\d+$ ]]; then
213222
exit 1
214223
fi
215224
@@ -223,7 +232,6 @@ jobs:
223232

224233
# Create release
225234
- name: Create release
226-
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1
227-
with:
228-
generateReleaseNotes: true
229-
artifacts: .build/cache-warmup.phar,.build/cache-warmup.phar.asc
235+
env:
236+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
237+
run: gh release create "${REF_NAME}" --generate-notes .build/cache-warmup.phar .build/cache-warmup.phar.asc

.github/workflows/tests.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
branches:
88
- main
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
prepare:
1215
name: Prepare workflow
@@ -33,7 +36,7 @@ jobs:
3336
steps:
3437
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3538
with:
36-
fetch-depth: 0
39+
persist-credentials: false
3740

3841
# Prepare environment
3942
- name: Setup PHP
@@ -62,7 +65,7 @@ jobs:
6265
steps:
6366
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
6467
with:
65-
fetch-depth: 0
68+
persist-credentials: false
6669

6770
# Prepare environment
6871
- name: Setup PHP
@@ -101,7 +104,7 @@ jobs:
101104
steps:
102105
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
103106
with:
104-
fetch-depth: 0
107+
persist-credentials: false
105108

106109
# Download artifact
107110
- name: Download coverage artifact
@@ -124,7 +127,7 @@ jobs:
124127
steps:
125128
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
126129
with:
127-
fetch-depth: 0
130+
persist-credentials: false
128131

129132
# Prepare environment
130133
- name: Setup PHP

0 commit comments

Comments
 (0)