Skip to content

Commit 63380b7

Browse files
committed
ci: upgrade ci with security fix
1 parent f8cda36 commit 63380b7

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,109 @@
11
name: CI
22

3-
on: [push]
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
actions: read
8+
id-token: none
49

510
jobs:
611
composer:
712
runs-on: ubuntu-latest
813
strategy:
914
matrix:
10-
php: [ 8.1, 8.2 ]
15+
php: [ 8.1, 8.2, 8.3, 8.4 ]
1116

1217
steps:
13-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1419

1520
- name: Cache Composer dependencies
16-
uses: actions/cache@v3
21+
uses: actions/cache@v4
1722
with:
1823
path: /tmp/composer-cache
19-
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
24+
key: ${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
2025

2126
- name: Composer install
2227
uses: php-actions/composer@v6
23-
env:
24-
COMPOSER_ROOT_VERSION: dev-master
2528
with:
2629
php_version: ${{ matrix.php }}
2730

2831
- name: Archive build
29-
run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./
32+
run: mkdir /tmp/github-actions/ && tar --exclude=".git" -cvf /tmp/github-actions/build.tar ./
3033

3134
- name: Upload build archive for test runners
32-
uses: actions/upload-artifact@v3
35+
uses: actions/upload-artifact@v4
3336
with:
34-
name: build-artifact
37+
name: build-artifact-${{ matrix.php }}
3538
path: /tmp/github-actions
3639

3740
phpunit:
3841
runs-on: ubuntu-latest
3942
needs: [ composer ]
4043
strategy:
4144
matrix:
42-
php: [ 8.1, 8.2 ]
45+
php: [ 8.1, 8.2, 8.3, 8.4 ]
4346

4447
outputs:
4548
coverage: ${{ steps.store-coverage.outputs.coverage_text }}
4649

4750
steps:
48-
- uses: actions/download-artifact@v3
51+
- uses: actions/download-artifact@v4
4952
with:
50-
name: build-artifact
53+
name: build-artifact-${{ matrix.php }}
5154
path: /tmp/github-actions
5255

5356
- name: Extract build archive
5457
run: tar -xvf /tmp/github-actions/build.tar ./
5558

5659
- name: PHP Unit tests
57-
uses: php-actions/phpunit@v3
60+
uses: php-actions/phpunit@v4
5861
env:
5962
XDEBUG_MODE: cover
6063
with:
61-
version: "10.1"
6264
php_version: ${{ matrix.php }}
6365
php_extensions: xdebug
6466
coverage_text: _coverage/coverage.txt
6567
coverage_clover: _coverage/clover.xml
6668

6769
- name: Store coverage data
68-
uses: actions/upload-artifact@v3
70+
uses: actions/upload-artifact@v4
6971
with:
70-
name: code-coverage
72+
name: code-coverage-${{ matrix.php }}-${{ github.run_number }}
7173
path: _coverage
7274

7375
coverage:
7476
runs-on: ubuntu-latest
7577
needs: [ phpunit ]
78+
strategy:
79+
matrix:
80+
php: [ 8.1, 8.2, 8.3, 8.4 ]
7681

7782
steps:
78-
- uses: actions/checkout@v3
83+
- uses: actions/checkout@v4
7984

80-
- uses: actions/download-artifact@v3
85+
- uses: actions/download-artifact@v4
8186
with:
82-
name: code-coverage
87+
name: code-coverage-${{ matrix.php }}-${{ github.run_number }}
8388
path: _coverage
8489

8590
- name: Output coverage
8691
run: cat "_coverage/coverage.txt"
8792

8893
- name: Upload to Codecov
89-
uses: codecov/codecov-action@v3
94+
uses: codecov/codecov-action@v5
9095

9196
phpstan:
9297
runs-on: ubuntu-latest
9398
needs: [ composer ]
9499
strategy:
95100
matrix:
96-
php: [ 8.1, 8.2 ]
101+
php: [ 8.1, 8.2, 8.3, 8.4 ]
97102

98103
steps:
99-
- uses: actions/download-artifact@v3
104+
- uses: actions/download-artifact@v4
100105
with:
101-
name: build-artifact
106+
name: build-artifact-${{ matrix.php }}
102107
path: /tmp/github-actions
103108

104109
- name: Extract build archive
@@ -107,22 +112,21 @@ jobs:
107112
- name: PHP Static Analysis
108113
uses: php-actions/phpstan@v3
109114
with:
110-
version: "1.12.6"
111115
php_version: ${{ matrix.php }}
112116
path: src/
113-
level: 7
117+
configuration: phpstan.neon
114118

115119
phpmd:
116120
runs-on: ubuntu-latest
117121
needs: [ composer ]
118122
strategy:
119123
matrix:
120-
php: [ 8.1, 8.2 ]
124+
php: [ 8.1, 8.2, 8.3, 8.4 ]
121125

122126
steps:
123-
- uses: actions/download-artifact@v3
127+
- uses: actions/download-artifact@v4
124128
with:
125-
name: build-artifact
129+
name: build-artifact-${{ matrix.php }}
126130
path: /tmp/github-actions
127131

128132
- name: Extract build archive
@@ -141,12 +145,12 @@ jobs:
141145
needs: [ composer ]
142146
strategy:
143147
matrix:
144-
php: [ 8.1, 8.2 ]
148+
php: [ 8.1, 8.2, 8.3, 8.4 ]
145149

146150
steps:
147-
- uses: actions/download-artifact@v3
151+
- uses: actions/download-artifact@v4
148152
with:
149-
name: build-artifact
153+
name: build-artifact-${{ matrix.php }}
150154
path: /tmp/github-actions
151155

152156
- name: Extract build archive
@@ -162,12 +166,15 @@ jobs:
162166
remove_old_artifacts:
163167
runs-on: ubuntu-latest
164168

169+
permissions:
170+
actions: write
171+
165172
steps:
166173
- name: Remove old artifacts for prior workflow runs on this repository
167174
env:
168175
GH_TOKEN: ${{ github.token }}
169176
run: |
170-
gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name == \"build-artifact\") | .id" > artifact-id-list.txt
177+
gh api "/repos/${{ github.repository }}/actions/artifacts" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt
171178
while read id
172179
do
173180
echo -n "Deleting artifact ID $id ... "

0 commit comments

Comments
 (0)