forked from redaxo/redaxo
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (87 loc) · 3.68 KB
/
code-style.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Code Style
on:
push:
branches: [main, bugfix, temp]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
env:
writable: ${{ github.event_name != 'push' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' && 1 || 0 }}
permissions:
contents: read
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event.pull_request.draft == false
permissions:
contents: write # for stefanzweifel/git-auto-commit-action to push code in repo
steps:
- name: Checkout
uses: actions/checkout@v3
if: env.writable == 1
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.BOT_TOKEN }}
- name: Checkout fork
uses: actions/checkout@v3
if: env.writable == 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none # disable xdebug, pcov
tools: cs2pr
- name: Composer install
uses: ramsey/composer-install@v2
with:
composer-options: --ansi --prefer-dist
- name: Fix code style
if: env.writable == 1
run: vendor/bin/php-cs-fixer list-files --config=.php-cs-fixer.dist.php | xargs -n 250 -P 3 vendor/bin/php-cs-fixer fix --diff --config=.php-cs-fixer.dist.php
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v4
if: env.writable == 1
with:
commit_message: Apply php-cs-fixer changes
commit_user_name: rex-bot
commit_user_email: [email protected]
- name: Check code style
if: env.writable == 0
run: vendor/bin/php-cs-fixer fix --ansi --diff --dry-run --format=checkstyle | cs2pr # check whether there are still errors left
rector:
permissions:
contents: write # for stefanzweifel/git-auto-commit-action to push code in repo
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event.pull_request.draft == false
steps:
- name: Checkout
uses: actions/checkout@v3
if: env.writable == 1
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.BOT_TOKEN }}
- name: Checkout fork
uses: actions/checkout@v3
if: env.writable == 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none # disable xdebug, pcov
- name: Composer install
uses: ramsey/composer-install@v2
with:
composer-options: --ansi --prefer-dist
- name: Fix code style
if: env.writable == 1
run: vendor/bin/rector process --no-progress-bar
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v4
if: env.writable == 1
with:
commit_message: Apply rector changes
commit_user_name: rex-bot
commit_user_email: [email protected]
- name: Check code style
run: vendor/bin/rector process --ansi --no-progress-bar --dry-run