Make CS Fixer fix in main branch #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PHP CS Fixer | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Check | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
php: | |
- "8.3" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup PHP | |
uses: shivammathur/[email protected] | |
with: | |
php-version: ${{ matrix.php }} | |
- name: Restore Composer package cache | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: "~/.cache/composer" | |
key: "php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}" | |
restore-keys: "php-${{ matrix.php }}-composer-" | |
- name: Install Composer dependencies | |
run: composer install --prefer-dist --no-interaction --ignore-platform-reqs | |
codestyle: | |
name: Code Style checks | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP and tools | |
uses: shivammathur/[email protected] | |
with: | |
php-version: 8.3 | |
tools: php-cs-fixer:3.65 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout main branch | |
run: | | |
git fetch origin | |
git checkout main || git checkout -b main origin/main | |
- name: Run PHP-CS-Fixer | |
run: php-cs-fixer fix --diff --ansi | |
- name: Commit changes | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
git add . | |
git commit -m "Apply PHP CS Fixer changes" || echo "No changes to commit" | |
- name: Push changes | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main |