Skip to content

Commit eca15b9

Browse files
committed
ci: make the whitespace checker more robust
In 32c83af (ci: github action - add check for whitespace errors, 2020-09-22), we introduced a GitHub workflow that automatically checks Pull Requests for whitespace problems. However, when affected lines contain one or more double quote characters, this workflow failed to attach the informative comment because the Javascript snippet incorrectly interpreted these quotes instead of using the `git log` output as-is. Let's fix that. While at it, let's `await` the result of the `createComment()` function. Finally, we enclose the log in the comment with ```...``` to avoid having the diff marker be misinterpreted as an enumeration bullet. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 32c83af commit eca15b9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.github/workflows/check-whitespace.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ jobs:
5858
- name: Add Check Output as Comment
5959
uses: actions/github-script@v3
6060
id: add-comment
61+
env:
62+
log: ${{ steps.check_out.outputs.checkout }}
6163
with:
6264
script: |
63-
github.issues.createComment({
65+
await github.issues.createComment({
6466
issue_number: context.issue.number,
6567
owner: context.repo.owner,
6668
repo: context.repo.repo,
67-
body: "Whitespace errors found in workflow ${{ github.workflow }}:\n\n${{ steps.check_out.outputs.checkout }}"
69+
body: `Whitespace errors found in workflow ${{ github.workflow }}:\n\n\`\`\`\n${process.env.log.replace(/\\n/g, "\n")}\n\`\`\``
6870
})
6971
if: ${{ failure() }}

0 commit comments

Comments
 (0)