Skip to content

Fix format action

Fix format action #73

Workflow file for this run

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