Skip to content

Commit 6fd79a0

Browse files
committed
better error reporting from unicode checker
1 parent cd22f67 commit 6fd79a0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

.github/workflows/unicode_warn.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
################################################################################
22
# File: .github/workflows/unicode_warn.yml
3-
# Version: 0.4
3+
# Version: 0.5
44
# Purpose: Detects Unicode in PRs and comments the results of findings in PR
55
# Authors: Michael Altfield <michael@michaelaltfield.net>
66
# Created: 2021-11-20
@@ -37,9 +37,21 @@ jobs:
3737
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3838
run: |
3939
apt-get update
40-
apt-get install -y git bsdmainutils
40+
apt-get install -y git bsdmainutils curl jq
4141
git clone "https://token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" .
4242
shell: bash
43+
44+
- name: Get link to this run
45+
run: |
46+
# https://stackoverflow.com/a/75734917
47+
workflow_id=$(curl -L \
48+
-H "Accept: application/vnd.github+json" \
49+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
50+
-H "X-GitHub-Api-Version: 2022-11-28" \
51+
https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT}/jobs | jq .jobs[].id )
52+
RUN_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${workflow_id}
53+
echo "RUN_URL=${RUN_URL}" >> $GITHUB_ENV
54+
shell: bash
4355

4456
- name: Check diff for unicode
4557
continue-on-error: true
@@ -109,14 +121,14 @@ jobs:
109121
issue_number: context.issue.number,
110122
owner: context.repo.owner,
111123
repo: context.repo.repo,
112-
body: "${{ env.UNICODE_HUMAN_RESULT }}"
124+
body: "${{ env.UNICODE_HUMAN_RESULT }}\n\n([source](${{ env.RUN_URL }}))"
113125
})
114126
115127
# Exit with or without error
116128
- name: Exit with or without error
117129
run: |
118130
119-
if [[ "${{ env.UNICODE_HUMAN_RESULT }}" | grep -Ei "ERROR|WARNING" ]]; then
131+
if [[ $(echo "${{ env.UNICODE_HUMAN_RESULT }}" | grep -Ei "ERROR|WARNING") ]]; then
120132
exit 1
121133
else
122134
exit 0

0 commit comments

Comments
 (0)