Skip to content

Commit

Permalink
Merge pull request #3349 from the-events-calendar/repo-sync/actions/m…
Browse files Browse the repository at this point in the history
…aster

🔄 synced file(s) with the-events-calendar/actions
  • Loading branch information
bordoni authored Oct 28, 2024
2 parents 10aba70 + 8cdbb9f commit e0f665e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
38 changes: 37 additions & 1 deletion .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
name: 'PHPCS'
on: [pull_request]
jobs:
conditional:
runs-on: ubuntu-latest
outputs:
has_no_php_changes: ${{ steps.skip.outputs.has_no_php_changes }}
steps:
# ------------------------------------------------------------------------------
# Checkout the repo
# ------------------------------------------------------------------------------
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 1000
token: ${{ secrets.GH_BOT_TOKEN }}
submodules: recursive
# ------------------------------------------------------------------------------
# Check if any PHP files have changed
# ------------------------------------------------------------------------------
- name: Check PHP file changes
id: skip
run: |
php_files=$(git diff ${{ github.event.pull_request.base.sha }} HEAD --name-only | grep -E '\.php$' || true)
num_php_files=$(echo "$php_files" | grep -c '^' || echo 0)
if [[ -z "$php_files" || "$num_php_files" -eq 0 ]]; then
echo "has_no_php_changes=1" >> $GITHUB_OUTPUT
echo "## No PHP files changed" >> $GITHUB_STEP_SUMMARY
echo "PHPCS will not run." >> $GITHUB_STEP_SUMMARY
else
echo "has_no_php_changes=0" >> $GITHUB_OUTPUT
echo "## Found PHP file changes" >> $GITHUB_STEP_SUMMARY
echo "Total changed PHP files: $num_php_files" >> $GITHUB_STEP_SUMMARY
echo "$php_files" | sed 's/^/- /' >> $GITHUB_STEP_SUMMARY
fi
phpcs:
needs:
- conditional
if: needs.conditional.outputs.has_no_php_changes == '0'
uses: stellarwp/github-actions/.github/workflows/phpcs.yml@main
with:
ref: ${{ github.event.inputs.ref }}
secrets:
access-token: ${{ secrets.GH_BOT_TOKEN }}
access-token: ${{ secrets.GH_BOT_TOKEN }}

0 comments on commit e0f665e

Please sign in to comment.