diff --git a/.github/actions/php-cs-fixer/action.yml b/.github/actions/php-cs-fixer/action.yml new file mode 100644 index 0000000..2b6cbee --- /dev/null +++ b/.github/actions/php-cs-fixer/action.yml @@ -0,0 +1,41 @@ +name: PHP CS Fixer +description: Run PHP CS Fixer in a Docker container + +inputs: + workspace: + description: 'The workspace directory to mount in the container' + required: true + args: + description: 'Additional arguments to pass to php-cs-fixer' + required: false + default: '--allow-risky=yes' + github-token: + description: 'GitHub token for authenticating with GHCR' + required: true + +runs: + using: composite + steps: + - name: Login to GitHub Container Registry + shell: bash + run: echo "${{ inputs.github-token }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Pull a Craftzing owned image + shell: bash + run: docker pull ghcr.io/craftzing/docker-images/php:8.4 + + - name: Run php-cs-fixer inside the container + shell: bash + run: | + docker run --rm \ + -v "${{ inputs.workspace }}:/app" \ + -w /app \ + ghcr.io/craftzing/docker-images/php:8.4 \ + bash -c " + VERSION=3.88.2 && \ + wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v\$VERSION/php-cs-fixer.phar -O php-cs-fixer && \ + chmod a+x php-cs-fixer && \ + mv php-cs-fixer /usr/local/bin/php-cs-fixer && \ + php-cs-fixer --version && \ + php-cs-fixer fix ${{ inputs.args }} + " diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 4f8a391..3e320bf 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -19,10 +19,12 @@ jobs: with: ref: ${{ github.head_ref }} - name: Run PHP CS fixer - uses: docker://oskarstark/php-cs-fixer-ga + uses: ./.github/actions/php-cs-fixer with: + workspace: ${{ github.workspace }} args: --config=.php-cs-fixer.dist.php --allow-risky=yes + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Commit CS fixes - uses: craftzing/git-auto-commit-action@v5 + uses: craftzing/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 with: commit_message: Fix code style violations