3 # Get the repo with the commits(+1) in the series.
4 # Process `git log --check` output to extract just the check errors.
5 # Add a comment to the pull request with the check errors.
9 types: [opened, synchronize]
13 runs-on: ubuntu-latest
15 - name: Set commit count
17 run: echo "COMMIT_DEPTH=$((1+$COMMITS))" >>$GITHUB_ENV
19 COMMITS: ${{ github.event.pull_request.commits }}
21 - uses: actions/checkout@v2
23 fetch-depth: ${{ env.COMMIT_DEPTH }}
25 - name: git log --check
39 if test -n "${commit}"
41 log="${log}\n${commit}"
46 log="${log}\n${dash} ${etc}"
50 done <<< $(git log --check --pretty=format:"---% h% s" -${{github.event.pull_request.commits}})
54 echo "::set-output name=checkout::"${log}""
58 - name: Add Check Output as Comment
59 uses: actions/github-script@v3
62 log: ${{ steps.check_out.outputs.checkout }}
65 await github.issues.createComment({
66 issue_number: context.issue.number,
67 owner: context.repo.owner,
68 repo: context.repo.repo,
69 body: `Whitespace errors found in workflow ${{ github.workflow }}:\n\n\`\`\`\n${process.env.log.replace(/\\n/g, "\n")}\n\`\`\``