-
Notifications
You must be signed in to change notification settings - Fork 1
38 lines (33 loc) · 1.18 KB
/
php-style-lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: "PHP Style Linting"
on:
pull_request:
merge_group:
jobs:
build_app:
name: "PHPCS"
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: cs2pr, phpcs
- name: Checkout code
uses: actions/checkout@v4
- name: Add Composer dependency credentials
run: echo '${{ secrets.COMPOSER_AUTH_JSON }}' > $GITHUB_WORKSPACE/auth.json
- name: Install Composer dependencies
run: composer install
- name: Run PHPCS
# Get the changed files from the PR via Github CLI.
# `grep` to only PHP files then remove deleted files via `find`.
# Run `phpcs` on the remaining files and pass output to `cs2pr`.
run: |
echo "Files for this PR:"
gh pr diff $PR --name-only | grep .php | xargs find 2> /dev/null | cat
gh pr diff $PR --name-only | grep .php | xargs find 2> /dev/null | xargs vendor/bin/phpcs -nq --report=checkstyle | cs2pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ github.event.pull_request.number }}