-
Notifications
You must be signed in to change notification settings - Fork 181
34 lines (34 loc) · 1.17 KB
/
format.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
name: Format
on:
pull_request:
paths: ['**.php']
jobs:
pint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- uses: shivammathur/setup-php@v2
with:
php-version: 8.3
- uses: ramsey/composer-install@v2
- name: Run Pint
id: format
run: |
delimiter=$RANDOM
echo "summary<<${delimiter}" >> $GITHUB_OUTPUT
vendor/bin/pint >> $GITHUB_OUTPUT
echo $delimiter >> $GITHUB_OUTPUT
- name: Check for changed files
run: echo "changed=$(git diff --quiet && echo false || echo true)" >> $GITHUB_ENV
- name: Commit changes
if: env.changed == 'true'
run: |
git config --global user.name github-actions
git config --global user.email github-actions[bot]@users.noreply.github.com
# Trim leading and trailing whitespace from each line
git commit -a -m "Format" -m "$(echo '${{ steps.format.outputs.summary }})' | awk '{$1=$1};1')"
git push