Skip to content

PHPCSFixer

PHPCSFixer #1

Workflow file for this run

name: PHPCSFixer
on:
workflow_dispatch:
inputs:
owner:
description: 'Owner of the repo'
required: true
repo:
description: 'Repo to run against'
required: true
branch:
description: 'Branch to run against'
required: true
default: main
php-version:
description: 'PHP version to use'
required: true
default: 8.2
rules:
description: 'Rules to use'
required: true
default: "@PER-CS2.0,no_unused_imports"
jobs:
fix_codestyle:
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: "${{ vars.APP_ID }}"
private-key: "${{ secrets.APP_PRIVATE_KEY }}"
repositories: "${{ inputs.repo }}"
- uses: actions/checkout@v4
with:
repository: "${{ inputs.owner }}/${{ inputs.repo }}"
token: "${{ steps.generate-token.outputs.token }}"
ref: "${{ inputs.branch }}"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ inputs.php-version }}"
tools: php-cs-fixer
- name: Run CSFixer
run: |
php-cs-fixer fix . --rules="${{ inputs.rules }}"
if ! git diff HEAD --quiet; then
githubUsername="${{ vars.GITHUB_USERNAME }}"
githubId="${{ vars.GITHUB_USER_ID }}"
githubEmail="${githubId}+${githubUsername}[bot]@users.noreply.github.com"
commitSha=$(git rev-parse --short HEAD)
git config --global user.name "${githubUsername}"
git config --global user.email "${githubEmail}"
git add .
git commit -m "Run CSFixer"
git push origin "HEAD:${{ inputs.branch }}"
fi