name: phpcbf-oneshot # One-shot workflow: runs phpcbf against the current branch and commits the # auto-fixes back. Triggered manually via workflow_dispatch. Intended to be # deleted in a follow-up commit once the fix-up has landed. on: workflow_dispatch: permissions: contents: write jobs: phpcbf: name: phpcbf autofix + commit runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ github.ref }} token: ${{ secrets.GITHUB_TOKEN }} persist-credentials: true - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: '8.1' coverage: none tools: composer:v2, phpcbf, phpcs - name: Install WordPress Coding Standards run: | composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true composer global require --no-interaction \ "dealerdirect/phpcodesniffer-composer-installer:^1.0" \ "wp-coding-standards/wpcs:^3.0" \ "phpcsstandards/phpcsutils:^1.0" \ "phpcsstandards/phpcsextra:^1.0" - name: Run phpcbf run: | # phpcbf exits 1 when fixes applied, 2 when unfixable, 0 when clean. # Do not let a non-zero exit abort the workflow. phpcbf --standard=phpcs.xml \ --extensions=php \ --ignore=vendor/*,tests/*,node_modules/* \ includes/ prautoblogger.php uninstall.php || true - name: Verify phpcs clean after autofix run: | phpcs --standard=phpcs.xml \ --extensions=php \ --ignore=vendor/*,tests/*,node_modules/* \ --warning-severity=0 \ --report=summary \ includes/ prautoblogger.php uninstall.php - name: Commit and push fixes run: | git config user.name "peptiderepo" git config user.email "peptiderepo@users.noreply.github.com" if git diff --quiet; then echo "No changes to commit." exit 0 fi git add -A git commit -m "Opik Wave 1: phpcbf autofix (WPCS)" git push origin HEAD:${GITHUB_REF_NAME}