forked from humhub/humhub
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (57 loc) · 2.08 KB
/
php-cs-fixer.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
name: PHP CS Fixer
on:
push:
branches:
- master
- develop
- next
paths:
- '**.php'
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check the commit message for skipping PHP-CS-Fixer
id: check_phpcs_skip
run: |
if git log -1 --pretty=%B | grep -q '\[SKIP-PHPCS\]'; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "Skip PHP-CS-Fixer because the commit message contains [SKIP-PHPCS]."
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "Proceeding with PHP-CS-Fixer steps."
fi
- uses: actions/cache@v4
if: steps.check_phpcs_skip.outputs.skip == 'false'
with:
path: .php-cs-fixer.cache
key: ${{ runner.OS }}-${{ github.repository }}-phpcsfixer-${{ github.sha }}
restore-keys: |
${{ runner.OS }}-${{ github.repository }}-phpcsfixer-
- name: Run PHP-CS-Fixer
if: steps.check_phpcs_skip.outputs.skip == 'false'
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php-cs-fixer.php
- name: Create branch and Pull Request for new changes
if: steps.check_phpcs_skip.outputs.skip == 'false'
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
if git diff --quiet; then
echo "No changes detected by PHP-CS-Fixer. Skipping commit and PR creation."
exit 0
fi
PHP_FIXER_DATETIME=$(date +%Y-%m-%d-%H%M%S)
git checkout -b "php-fixer/$PHP_FIXER_DATETIME"
git add -u
git commit -m "Autocommit PHP CS Fixer"
git push origin "php-fixer/$PHP_FIXER_DATETIME"
gh pr create \
--title "PHP CS Fixer $PHP_FIXER_DATETIME" \
--body "This Pull Request includes automated changes from PHP-CS-Fixer." \
--base "${{ github.ref_name }}" \
--head "php-fixer/$PHP_FIXER_DATETIME"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}