-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.34 KB
/
format-code.yml
File metadata and controls
53 lines (45 loc) · 1.34 KB
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
name: Run format-code
on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: ./vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: format code
run: bash commands php-cs-fixer
- name: Commit and push changelog to PR branch
env:
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: actions@github.com
run: |
git config user.name "$GIT_AUTHOR_NAME"
git config user.email "$GIT_AUTHOR_EMAIL"
git add .
if git diff --staged --quiet; then
echo "No changes to commit."
exit 0
fi
commit_msg="style: Fix PHP code style issues"
git commit -m "$commit_msg"
git push origin HEAD:${{ github.event.pull_request.head.ref }}