1
1
name : ' PHPCS'
2
2
on : [pull_request]
3
3
jobs :
4
+ conditional :
5
+ runs-on : ubuntu-latest
6
+ outputs :
7
+ has_no_php_changes : ${{ steps.skip.outputs.has_no_php_changes }}
8
+ steps :
9
+ # ------------------------------------------------------------------------------
10
+ # Checkout the repo
11
+ # ------------------------------------------------------------------------------
12
+ - name : Checkout the repository
13
+ uses : actions/checkout@v4
14
+ with :
15
+ fetch-depth : 1000
16
+ token : ${{ secrets.GH_BOT_TOKEN }}
17
+ submodules : recursive
18
+ # ------------------------------------------------------------------------------
19
+ # Check if any PHP files have changed
20
+ # ------------------------------------------------------------------------------
21
+ - name : Check PHP file changes
22
+ id : skip
23
+ run : |
24
+ php_files=$(git diff ${{ github.event.pull_request.base.sha }} HEAD --name-only | grep -E '\.php$' || true)
25
+ num_php_files=$(echo "$php_files" | grep -c '^' || echo 0)
26
+
27
+ if [[ -z "$php_files" || "$num_php_files" -eq 0 ]]; then
28
+ echo "has_no_php_changes=1" >> $GITHUB_OUTPUT
29
+ echo "## No PHP files changed" >> $GITHUB_STEP_SUMMARY
30
+ echo "PHPCS will not run." >> $GITHUB_STEP_SUMMARY
31
+ else
32
+ echo "has_no_php_changes=0" >> $GITHUB_OUTPUT
33
+ echo "## Found PHP file changes" >> $GITHUB_STEP_SUMMARY
34
+ echo "Total changed PHP files : $num_php_files" >> $GITHUB_STEP_SUMMARY
35
+ echo "$php_files" | sed 's/^/- /' >> $GITHUB_STEP_SUMMARY
36
+ fi
4
37
phpcs :
38
+ needs :
39
+ - conditional
40
+ if : needs.conditional.outputs.has_no_php_changes == '0'
5
41
uses : stellarwp/github-actions/.github/workflows/phpcs.yml@main
6
42
with :
7
43
ref : ${{ github.event.inputs.ref }}
8
44
secrets :
9
- access-token : ${{ secrets.GH_BOT_TOKEN }}
45
+ access-token : ${{ secrets.GH_BOT_TOKEN }}
0 commit comments