Adding G431 product id #436
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Whitespace Check | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| check-whitespace: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 0 | |
| - name: Check for whitespace errors | |
| id: check | |
| run: | | |
| # Compare PR branch against base branch | |
| BASE_SHA=${{ github.event.pull_request.base.sha }} | |
| HEAD_SHA=${{ github.event.pull_request.head.sha }} | |
| echo "Checking commits from $BASE_SHA to $HEAD_SHA" | |
| # git diff --check returns non-zero if whitespace errors exist | |
| if git diff --check "$BASE_SHA" "$HEAD_SHA" > errors.txt 2>&1; then | |
| echo "has_errors=false" >> $GITHUB_OUTPUT | |
| echo "### No Whitespace Issues" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "has_errors=true" >> $GITHUB_OUTPUT | |
| # Build summary | |
| { | |
| echo "### Whitespace Issues Found" | |
| echo "" | |
| echo "Files with whitespace errors (trailing spaces, spaces before tabs):" | |
| echo "" | |
| echo '```' | |
| cat errors.txt | |
| echo '```' | |
| echo "" | |
| echo "**To fix:** Run \`git rebase --whitespace=fix $BASE_SHA\` then force push." | |
| } >> $GITHUB_STEP_SUMMARY | |
| # Save for PR comment (using heredoc for multiline) | |
| { | |
| echo 'ERRORS<<EOF' | |
| cat errors.txt | |
| echo 'EOF' | |
| } >> $GITHUB_ENV | |
| fi | |
| # Always look for existing comment (to update or delete) | |
| - name: Find existing comment | |
| uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 | |
| id: find-comment | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: 'whitespace errors' | |
| # Delete old failure comment when check passes | |
| - name: Delete old comment if check passes | |
| if: steps.check.outputs.has_errors == 'false' && steps.find-comment.outputs.comment-id != '' | |
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
| with: | |
| script: | | |
| await github.rest.issues.deleteComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: ${{ steps.find-comment.outputs.comment-id }} | |
| }); | |
| # Create or update failure comment | |
| - name: Create or update PR comment | |
| if: steps.check.outputs.has_errors == 'true' | |
| uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
| with: | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| edit-mode: replace | |
| body: | | |
| ## Whitespace Check Failed | |
| Files in this PR have whitespace errors (trailing spaces, spaces before tabs, etc.): | |
| ``` | |
| ${{ env.ERRORS }} | |
| ``` | |
| ### How to fix | |
| ```bash | |
| # Automatically fix whitespace in your branch | |
| git rebase --whitespace=fix ${{ github.event.pull_request.base.sha }} | |
| git push --force-with-lease | |
| ``` | |
| --- | |
| *Checked at: ${{ github.event.pull_request.head.sha }}* | |
| - name: Fail if errors | |
| if: steps.check.outputs.has_errors == 'true' | |
| run: exit 1 |