style: apply php-cs-fixer fixes from coding-standard 0.7 #40
Workflow file for this run
This file contains hidden or 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: Format (PHP) | |
| on: | |
| push: | |
| paths: | |
| - '**.php' | |
| - 'composer.*' | |
| - 'phpcs.xml' | |
| jobs: | |
| format_php: | |
| name: Format PHP | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 7 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| # mtime needs to be restored for PHP-CS-Fixer cache to work correctly | |
| - name: Restore timestamps | |
| uses: chetan/git-restore-mtime-action@v2 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: 8.4 | |
| coverage: none | |
| tools: cs2pr | |
| env: | |
| COMPOSER_TOKEN: ${{ secrets.GH_TOKEN_FOR_COMPOSER_FOR_PRIVATE_REPOS }} | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: | | |
| echo "::set-output name=dir::$(composer config cache-files-dir)" | |
| - name: Retrieve Composer’s cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-composer- | |
| - name: Retrieve PHP-CS-Fixer’s cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: .php-cs-fixer.cache | |
| key: ${{ runner.os }}-php-cs-fixer-${{ hashFiles('.php-cs-fixer.php') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php-cs-fixer- | |
| - name: Retrieve PHPCS’s cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: .phpcs.cache | |
| key: ${{ runner.os }}-phpcs-${{ hashFiles('phpcs.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-phpcs- | |
| - name: Install Composer dependencies | |
| run: | | |
| composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_4_LICENSE_KEY }}" --ansi | |
| composer install --no-progress --prefer-dist | |
| - name: Detect PHP coding style issues | |
| id: lint_php | |
| run: composer cs:check | |
| continue-on-error: true | |
| - name: Fix detected PHP coding style issues (if any) | |
| if: ${{ steps.lint_php.outcome == 'failure' }} | |
| id: fix_php | |
| run: composer cs:fix | |
| continue-on-error: true | |
| - name: Commit PHP code-style fixes (if any) | |
| if: ${{ steps.lint_php.outcome == 'failure' }} | |
| uses: EndBug/add-and-commit@v9 | |
| with: | |
| message: '#15000 🪄️ Apply coding style fixes to PHP' | |
| committer_name: GitHub Actions | |
| committer_email: actions@github.com | |
| add: '*.php' | |
| pull: '--rebase --autostash' | |
| - name: Lint PHP coding style issues (if previously detected) | |
| if: ${{ steps.lint_php.outcome == 'failure' }} | |
| run: ./vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml | |
| - name: Show PHPCS results in on GitHub UI | |
| if: ${{ steps.lint_php.outcome == 'failure' }} | |
| run: cs2pr ./phpcs-report.xml |