Skip to content
41 changes: 41 additions & 0 deletions .github/actions/php-cs-fixer/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
"
6 changes: 4 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading