-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (67 loc) · 2.33 KB
/
format_php.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Format (PHP)
on:
push:
paths:
- '**.php'
- 'composer.*'
- 'phpcs.xml'
- 'IxDFCodingStandard/ruleset.xml'
jobs:
format_php:
name: Format PHP
runs-on: ubuntu-latest
timeout-minutes: 7
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none
tools: cs2pr
- name: Get Composer cache directory
id: composer-cache
run: |
echo "composer_dir={$(composer config cache-files-dir)}" >> $GITHUB_OUTPUT
- name: Retrieve Composer‘s cache
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.composer_dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install composer dependencies
run: "composer install --no-interaction --no-progress --no-scripts"
- name: Retrieve PHPCS‘s cache
uses: actions/cache@v3
with:
path: .cache/phpcs
key: ${{ runner.os }}-phpcs-${{ hashFiles('phpcs.xml') }}
restore-keys: |
${{ runner.os }}-phpcs-
- name: Detect PHP coding style issues
id: check_php_cs
run: composer cs:check
continue-on-error: true
- name: Fix detected PHP coding style issues (if any)
if: ${{ steps.check_php_cs.outcome == 'failure' }}
id: fix_php
run: composer cs:fix
continue-on-error: true
- name: Commit PHP code-style fixes (if any)
if: ${{ steps.check_php_cs.outcome == 'failure' }}
uses: EndBug/add-and-commit@v9
with:
message: "#15000 🪄️ Apply coding style fixes to PHP"
author_name: GitHub Actions
author_email: actions@github.com
add: '*.php'
pull: '--rebase --autostash'
- name: Lint PHP coding style issues (if previously detected)
if: ${{ steps.check_php_cs.outcome == 'failure' }}
run: composer cs:check -- --report-full --report-checkstyle=./phpcs-report.xml
- name: Show PHPCS results in on GitHub UI
if: ${{ steps.check_php_cs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml