Skip to content

Commit e0f665e

Browse files
authored
Merge pull request #3349 from the-events-calendar/repo-sync/actions/master
🔄 synced file(s) with the-events-calendar/actions
2 parents 10aba70 + 8cdbb9f commit e0f665e

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

.github/workflows/phpcs.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,45 @@
11
name: 'PHPCS'
22
on: [pull_request]
33
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
437
phpcs:
38+
needs:
39+
- conditional
40+
if: needs.conditional.outputs.has_no_php_changes == '0'
541
uses: stellarwp/github-actions/.github/workflows/phpcs.yml@main
642
with:
743
ref: ${{ github.event.inputs.ref }}
844
secrets:
9-
access-token: ${{ secrets.GH_BOT_TOKEN }}
45+
access-token: ${{ secrets.GH_BOT_TOKEN }}

0 commit comments

Comments
 (0)