|
1 | 1 | ################################################################################ |
2 | 2 | # File: .github/workflows/unicode_warn.yml |
3 | | -# Version: 0.4 |
| 3 | +# Version: 0.5 |
4 | 4 | # Purpose: Detects Unicode in PRs and comments the results of findings in PR |
5 | 5 | # Authors: Michael Altfield <michael@michaelaltfield.net> |
6 | 6 | # Created: 2021-11-20 |
|
37 | 37 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
38 | 38 | run: | |
39 | 39 | apt-get update |
40 | | - apt-get install -y git bsdmainutils |
| 40 | + apt-get install -y git bsdmainutils curl jq |
41 | 41 | git clone "https://token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" . |
42 | 42 | 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 |
43 | 55 |
|
44 | 56 | - name: Check diff for unicode |
45 | 57 | continue-on-error: true |
@@ -109,14 +121,14 @@ jobs: |
109 | 121 | issue_number: context.issue.number, |
110 | 122 | owner: context.repo.owner, |
111 | 123 | repo: context.repo.repo, |
112 | | - body: "${{ env.UNICODE_HUMAN_RESULT }}" |
| 124 | + body: "${{ env.UNICODE_HUMAN_RESULT }}\n\n([source](${{ env.RUN_URL }}))" |
113 | 125 | }) |
114 | 126 |
|
115 | 127 | # Exit with or without error |
116 | 128 | - name: Exit with or without error |
117 | 129 | run: | |
118 | 130 |
|
119 | | - if [[ "${{ env.UNICODE_HUMAN_RESULT }}" | grep -Ei "ERROR|WARNING" ]]; then |
| 131 | + if [[ $(echo "${{ env.UNICODE_HUMAN_RESULT }}" | grep -Ei "ERROR|WARNING") ]]; then |
120 | 132 | exit 1 |
121 | 133 | else |
122 | 134 | exit 0 |
|
0 commit comments