Skip to content

Commit

Permalink
Merge pull request #361 from wdssmq/up/phpcs-2024-04
Browse files Browse the repository at this point in the history
ci. 在 push 时自动规范 PHP  代码,保留原来的检查以兼顾 pr
  • Loading branch information
zhouzishu authored May 6, 2024
2 parents dfa1d95 + 66b5683 commit 378d0e6
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
name: Run PHPCS
on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
phpcs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Get file changes
id: get_file_changes
uses: tj-actions/changed-files@v44
- name: PHPCS check
if: steps.get_file_changes.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.get_file_changes.outputs.all_changed_files }}
run: |
echo "Running PHPCS on the following files:"
echo "${ALL_CHANGED_FILES}"
./vendor/bin/phpcs "${ALL_CHANGED_FILES}" --report=checkstyle
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Get file changes
id: get_file_changes
uses: tj-actions/changed-files@v44
- name: PHPCBF
if: steps.get_file_changes.outputs.any_changed == 'true' && github.event_name == 'push'
env:
ALL_CHANGED_FILES: ${{ steps.get_file_changes.outputs.all_changed_files }}
run: |
echo "Running PHPCBF on the following files:"
echo "${ALL_CHANGED_FILES}"
./vendor/bin/phpcbf ${ALL_CHANGED_FILES}
continue-on-error: true
- name: Commit files
if: github.event_name == 'push'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git status
git diff-index --quiet HEAD || (git commit -m "Auto Commit - phpcbf" -a --no-verify)
- name: Push changes
if: github.event_name == 'push'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: PHPCS check
if: steps.get_file_changes.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.get_file_changes.outputs.all_changed_files }}
run: |
echo "Running PHPCS on the following files:"
echo "${ALL_CHANGED_FILES}"
./vendor/bin/phpcs ${ALL_CHANGED_FILES}

0 comments on commit 378d0e6

Please sign in to comment.