Skip to content

Commit 984a06a

Browse files
author
Stefan Boonstra
committed
Simplify bash usage in github actions
1 parent 45f25c7 commit 984a06a

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

.github/workflows/testing-suite.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ jobs:
44
PHP:
55
strategy:
66
matrix:
7-
php-version: [8.1, 8.2, 8.3, 8.4]
7+
php:
8+
- {version: 8.1, tasks: 'composer,jsonlint,xmllint,yamllint,phpcs,phplint,phpmd,phpstan,securitychecker_enlightn'}
9+
- {version: 8.2, tasks: 'composer,jsonlint,xmllint,yamllint,phpcs,phplint,phpmd,phpstan,securitychecker_enlightn'}
10+
- {version: 8.3}
11+
- {version: 8.4}
812
runs-on: ubuntu-latest
913
container:
10-
image: ${{ matrix.php-version == '8.1' && 'srcoder/development-php:php81-fpm' ||
11-
matrix.php-version == '8.2' && 'srcoder/development-php:php82-fpm' ||
12-
matrix.php-version == '8.3' && 'srcoder/development-php:php83-fpm' ||
13-
matrix.php-version == '8.4' && 'srcoder/development-php:php84-fpm' }}
14+
image: ${{ matrix.php.version == '8.1' && 'srcoder/development-php:php81-fpm' ||
15+
matrix.php.version == '8.2' && 'srcoder/development-php:php82-fpm' ||
16+
matrix.php.version == '8.3' && 'srcoder/development-php:php83-fpm' ||
17+
matrix.php.version == '8.4' && 'srcoder/development-php:php84-fpm' }}
1418
steps:
1519
- name: Checkout
1620
uses: actions/checkout@v2
@@ -23,8 +27,8 @@ jobs:
2327

2428
- name: Run GrumPHP Tasks
2529
run: |
26-
if [[ "${{ matrix.php-version }}" == "8.1" || "${{ matrix.php-version }}" == "8.2" ]]; then
27-
composer2 exec -v grumphp -- run --tasks=composer,jsonlint,xmllint,yamllint,phpcs,phplint,phpmd,phpstan,securitychecker_enlightn
30+
if [[ ${{ matrix.php.tasks }} ]]; then
31+
composer2 exec -v grumphp -- run --tasks=${{ matrix.php.tasks }}
2832
else
2933
composer2 exec -v grumphp -- run
3034
fi

docs/examples/github-actions.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ jobs:
1010
PHP:
1111
strategy:
1212
matrix:
13-
php-version: [8.1, 8.2, 8.3, 8.4]
13+
php:
14+
- {version: 8.1, tasks: 'composer,jsonlint,xmllint,yamllint,phpcs,phplint,phpmd,phpstan,securitychecker_enlightn'}
15+
- {version: 8.2, tasks: 'composer,jsonlint,xmllint,yamllint,phpcs,phplint,phpmd,phpstan,securitychecker_enlightn'}
16+
- {version: 8.3}
17+
- {version: 8.4}
1418
runs-on: ubuntu-latest
1519
container:
16-
image: ${{ matrix.php-version == '8.1' && 'srcoder/development-php:php81-fpm' ||
17-
matrix.php-version == '8.2' && 'srcoder/development-php:php82-fpm' ||
18-
matrix.php-version == '8.3' && 'srcoder/development-php:php83-fpm' ||
19-
matrix.php-version == '8.4' && 'srcoder/development-php:php84-fpm' }}
20+
image: ${{ matrix.php.version == '8.1' && 'srcoder/development-php:php81-fpm' ||
21+
matrix.php.version == '8.2' && 'srcoder/development-php:php82-fpm' ||
22+
matrix.php.version == '8.3' && 'srcoder/development-php:php83-fpm' ||
23+
matrix.php.version == '8.4' && 'srcoder/development-php:php84-fpm' }}
2024
steps:
2125
- name: Checkout
2226
uses: actions/checkout@v2
@@ -29,12 +33,10 @@ jobs:
2933

3034
- name: Run GrumPHP Tasks
3135
run: |
32-
if [[ "${{ matrix.php-version }}" == "8.1" || "${{ matrix.php-version }}" == "8.2" ]]; then
33-
composer2 exec -v grumphp -- run --tasks=composer,jsonlint,xmllint,yamllint,phpcs,phplint,phpmd,phpstan,securitychecker_enlightn
36+
if [[ ${{ matrix.php.tasks }} ]]; then
37+
composer2 exec -v grumphp -- run --tasks=${{ matrix.php.tasks }}
3438
else
3539
composer2 exec -v grumphp -- run
3640
fi
3741
shell: bash
38-
39-
4042
```

0 commit comments

Comments
 (0)