Skip to content

Commit 9b972c4

Browse files
committed
feat: Add support for custom working directory (phpcs)
1 parent 5add8b6 commit 9b972c4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

.github/workflows/php-coding-standards.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ on:
2323
default: "--graceful-warnings ./phpcs-report.xml"
2424
required: false
2525
type: string
26+
WORKING_DIRECTORY:
27+
description: The working directory where to run the coding standards analysis.
28+
default: '.'
29+
required: false
30+
type: string
2631
secrets:
2732
COMPOSER_AUTH_JSON:
2833
description: Authentication for privately hosted packages and repositories as a JSON formatted object.
@@ -32,6 +37,10 @@ jobs:
3237
php-coding-standards:
3338
name: PHP Coding standards
3439
runs-on: ubuntu-latest
40+
defaults:
41+
run:
42+
shell: bash
43+
working-directory: ${{ inputs.WORKING_DIRECTORY }}
3544
env:
3645
COMPOSER_AUTH: "${{ secrets.COMPOSER_AUTH_JSON }}"
3746
steps:
@@ -46,15 +55,22 @@ jobs:
4655
PHP_VERSION: ${{ inputs.PHP_VERSION }}
4756
PHP_TOOLS: "composer, cs2pr"
4857
COMPOSER_CONFIG: ${{ vars.COMPOSER_CONFIG_JSON }}
58+
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
4959

5060
- name: Get changed files
5161
id: changed-files
52-
uses: tj-actions/changed-files@v45
62+
uses: tj-actions/changed-files@v47
63+
with:
64+
path: ${{ inputs.WORKING_DIRECTORY }}
65+
files: |
66+
**/*.php
5367
5468
- name: Run PHP_CS
5569
if: steps.changed-files.outputs.all_changed_files != ''
5670
run: ./vendor/bin/phpcs ${{ inputs.PHPCS_ARGS }} ${{ join(steps.changed-files.outputs.all_changed_files, ' ') }}
5771

5872
- name: Annotate PHP_CodeSniffer report
59-
if: ${{ always() }}
60-
run: cs2pr ${{ inputs.CS2PR_ARGS }}
73+
if: ${{ always() && steps.changed-files.outputs.all_changed_files != '' }}
74+
run: |
75+
sed -i 's|name="|name="${{ inputs.WORKING_DIRECTORY }}/|g' ./phpcs-report.xml
76+
cs2pr ${{ inputs.CS2PR_ARGS }}

0 commit comments

Comments
 (0)