With this action you can run PHP-CS-Fixer in your GitHub Actions workflow.
NOTE: If you didn't create a
.php-cs-fixer.dist.php
file, do that first before adding this workflow. An example of this file created by the creators of PHP-CS-Fixer can be found here.
Define your GitHub workflow.
# .github/workflows/php-cs-fixer.yml
name: PHP-CS-Fixer
on:
pull_request:
types: [review_requested, ready_for_review]
jobs:
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v4
-
name: Run PHP-CS-Fixer
uses: erkenes/php-cs-fixer-action@main
You can specify the PHP version to use by adding it as a prefix to the action version.
# .github/workflows/php-cs-fixer.yml
name: PHP-CS-Fixer
on:
pull_request:
types: [review_requested, ready_for_review]
jobs:
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v4
# PHP 8.3 (equal to main)
-
name: Run PHP-CS-Fixer
uses: erkenes/php-cs-fixer-action@php8.3-1.0.0
# PHP 8.2
-
name: Run PHP-CS-Fixer
uses: erkenes/php-cs-fixer-action@php8.2-1.0.0
# PHP 8.1
-
name: Run PHP-CS-Fixer
uses: erkenes/php-cs-fixer-action@php8.1-1.0.0
To commit the changes automatically to the branch of the pull request, you can use the following configuration:
# .github/workflows/php-cs-fixer.yml
jobs:
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v4
-
name: Run PHP-CS-Fixer
uses: erkenes/php-cs-fixer-action@main
-
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842
with:
commit_message: 'fix: Apply php-cs-fixer changes'
docker build \
--build-arg "PHP_VERSION=8.3" \
--build-arg "PHP_CS_FIXER_VERSION=3.54.0" \
--tag "erkenes/php-cs-fixer-action:local" \
.