@@ -28,47 +28,15 @@ jobs:
2828 github_token : ${{ secrets.GITHUB_TOKEN }}
2929
3030 - name : Update or add PR comment
31- env :
32- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
33- PR : ${{ github.event.pull_request.number }}
34- REPO : ${{ github.repository }}
35- run : |
36- set -euo pipefail
37-
38- BADGE_DIR="wiki/${REPO}"
39- PREFIX="https://github.com/${REPO}/${BADGE_DIR}/"
40-
41- COMMENT=""
42-
43- if [ -d "$BADGE_DIR" ]; then
44- for f in "$BADGE_DIR"/*.svg; do
45- [ -e "$f" ] || continue
46- FILE=$(basename "$f")
47- COMMENT+="[]() "
48- done
49- fi
50-
51- COMMENT+="<!-- BadgeGeneratorComment -->"
52-
53- # escape newlines for JSON
54- JSON_BODY=$(printf '%s' "$COMMENT" | jq -Rs .)
55-
56- COMMENTS=$(curl -s -H "Authorization: token $GH_TOKEN" \
57- -H "Accept: application/vnd.github.v3+json" \
58- "https://api.github.com/repos/${REPO}/issues/${PR}/comments")
59-
60- ID=$(echo "$COMMENTS" | jq -r '.[] | select(.body|contains("<!-- BadgeGeneratorComment -->")) | .id')
61-
62- if [ -n "$ID" ]; then
63- curl -s -X PATCH \
64- -H "Authorization: token $GH_TOKEN" \
65- -H "Accept: application/vnd.github.v3+json" \
66- -d "{\"body\":$JSON_BODY}" \
67- "https://api.github.com/repos/${REPO}/issues/comments/${ID}"
68- else
69- curl -s -X POST \
70- -H "Authorization: token $GH_TOKEN" \
71- -H "Accept: application/vnd.github.v3+json" \
72- -d "{\"body\":$JSON_BODY}" \
73- "https://api.github.com/repos/${REPO}/issues/${PR}/comments"
74- fi
31+ uses : DARMA-tasking/comment-on-pr@master
32+ with :
33+ repo_owner : ${{ github.event.repository.owner.login }}
34+ repo_name : ${{ github.event.repository.name }}
35+ pr_number : ${{ github.event.pull_request.number }}
36+ comment_title : " Generated badges"
37+ comment_content : |
38+ []()
39+ []()
40+ []()
41+ []()
42+ github_token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments