-
Notifications
You must be signed in to change notification settings - Fork 2
45 lines (39 loc) · 1.2 KB
/
phpcs.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
39
40
41
42
43
44
45
name: PHP CodeSniffer
on:
pull_request:
paths:
- '**.php'
push:
paths:
- '**.php'
jobs:
phpcs:
name: PHP CodeSniffer
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
- name: Install dependencies
run: composer install
- name: Run PHP CodeSniffer
run: |
vendor/bin/phpcs -p --standard=phpcs.xml --report=checkstyle --runtime-set ignore_warnings_on_exit 1 | cs2pr
- name: Post PHPCS results as PR comment
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const phpcsOutput = fs.readFileSync('phpcs-results.txt', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## PHP CodeSniffer Results\n\n```\n' + phpcsOutput + '\n```'
});