3 # Get the repository with all commits to ensure that we can analyze
4 # all of the commits contributed via the Pull Request.
5 # Process `git log --check` output to extract just the check errors.
6 # Exit with failure upon white-space issues.
10 types: [opened, synchronize]
12 # Avoid unnecessary builds. Unlike the main CI jobs, these are not
13 # ci-configurable (but could be).
15 group: ${{ github.workflow }}-${{ github.ref }}
16 cancel-in-progress: true
20 runs-on: ubuntu-latest
22 - uses: actions/checkout@v3
26 - name: git log --check
29 baseSha=${{github.event.pull_request.base.sha}}
35 while read dash sha etc
39 if test -z "${commit}"
44 commitText="${sha} ${etc}"
45 commitTextmd="[${sha}](https://github.com/${{ github.repository }}/commit/${sha}) ${etc}"
50 if test -n "${commit}"
52 problems+=("1) --- ${commitTextmd}")
54 echo "--- ${commitText}"
58 *:[1-9]*:) # contains file and line number information
60 problems+=("[${dash}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${dash%%:*}#L${dashend%:}) ${sha} ${etc}")
63 problems+=("\`${dash} ${sha} ${etc}\`")
66 echo "${dash} ${sha} ${etc}"
69 done <<< $(git log --check --pretty=format:"---% h% s" ${baseSha}..)
71 if test ${#problems[*]} -gt 0
73 if test -z "${commit}"
75 goodparent=${baseSha: 0:7}
77 echo "🛑 Please review the Summary output for further information."
78 echo "### :x: A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY
79 echo "" >>$GITHUB_STEP_SUMMARY
80 echo "Run these commands to correct the problem:" >>$GITHUB_STEP_SUMMARY
81 echo "1. \`git rebase --whitespace=fix ${goodparent}\`" >>$GITHUB_STEP_SUMMARY
82 echo "1. \`git push --force\`" >>$GITHUB_STEP_SUMMARY
83 echo " " >>$GITHUB_STEP_SUMMARY
84 echo "Errors:" >>$GITHUB_STEP_SUMMARY
85 for i in "${problems[@]}"
87 echo "${i}" >>$GITHUB_STEP_SUMMARY