1- name : Generate Badge
1+ name : Generate Badges
22
33on :
44 pull_request :
55
66jobs :
77 generate-badge :
88 runs-on : ubuntu-latest
9- name : Generate Badge
10- strategy :
11- matrix :
12- image : ["vt-build-amd64-alpine-3-16-clang-cpp",
13- " vt-build-amd64-ubuntu-20-04-clang-10-cpp" ,
14- " vt-build-amd64-ubuntu-20-04-clang-9-cpp" ,
15- " vt-build-amd64-ubuntu-20-04-gcc-10-cpp" ,
16- " vt-build-amd64-ubuntu-20-04-gcc-10-openmpi-cpp" ,
17- " vt-build-amd64-ubuntu-20-04-gcc-9-cpp" ,
18- " vt-build-amd64-ubuntu-20-04-gcc-9-cuda-11-4-3-cpp" ,
19- " vt-build-amd64-ubuntu-20-04-gcc-9-cuda-12-2-0-cpp" ,
20- " vt-build-amd64-ubuntu-20-04-icpx-cpp" ,
21- " vt-build-amd64-ubuntu-22-04-clang-11-cpp" ,
22- " vt-build-amd64-ubuntu-22-04-clang-12-cpp" ,
23- " vt-build-amd64-ubuntu-22-04-clang-13-cpp" ,
24- " vt-build-amd64-ubuntu-22-04-clang-14-cpp" ,
25- " vt-build-amd64-ubuntu-22-04-clang-15-cpp" ,
26- " vt-build-amd64-ubuntu-22-04-gcc-11-cpp" ,
27- " vt-build-amd64-ubuntu-22-04-gcc-12-cpp" ,
28- " vt-build-amd64-ubuntu-22-04-gcc-12-vtk-cpp" ,
29- " vt-build-amd64-ubuntu-22-04-gcc-12-zoltan-cpp" ,
30- " vt-build-amd64-ubuntu-24-04-clang-16-cpp" ,
31- " vt-build-amd64-ubuntu-24-04-clang-16-vtk-cpp" ,
32- " vt-build-amd64-ubuntu-24-04-clang-16-zoltan-cpp" ,
33- " vt-build-amd64-ubuntu-24-04-clang-17-cpp" ,
34- " vt-build-amd64-ubuntu-24-04-clang-18-cpp" ,
35- " vt-build-amd64-ubuntu-24-04-gcc-13-cpp" ,
36- " vt-build-amd64-ubuntu-24-04-gcc-14-cpp" ,
37- " vt-build-amd64-ubuntu-20-04-gcc-10-openmpi-cpp-spack" ]
38- result : ["success", "failure"]
9+ name : Generate Badges
3910
4011 steps :
4112 - uses : actions/checkout@v4
@@ -44,59 +15,71 @@ jobs:
4415 if : always()
4516 uses : DARMA-tasking/badge-generator@1-initial-version
4617 with :
47- name : ${{ matrix.image }}-${{ matrix.result }}
48- result : ${{ matrix.result }}
18+ names : |
19+ vt-build-amd64-alpine-3-16-clang-cpp
20+ vt-build-amd64-ubuntu-20-04-gcc-9-cuda-12-2-0-cpp
21+ vt-build-amd64-ubuntu-20-04-gcc-10-openmpi-cpp-spack
22+ vt-build-amd64-ubuntu-22-04-gcc-12-cpp
23+ results : |
24+ success
25+ cancelled
26+ failure
27+ failure
4928 github_token : ${{ secrets.GITHUB_TOKEN }}
5029
5130 comment-on-pr :
52- runs-on : ubuntu-latest
5331 needs : generate-badge
32+ runs-on : ubuntu-latest
5433 if : always()
5534 steps :
56- - uses : actions/checkout@v4
57- - name : Update or add comment to pull request
35+ - name : Clone wiki
5836 env :
5937 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60- PR_NUMBER : ${{ github.event.pull_request.number }}
61- REPO : ${{ github.repository }}
6238 run : |
63- PREFIX_STRING= "https://github.com/DARMA-tasking/badge-generator/ wiki/"
39+ git clone "https://x-access-token:${GITHUB_TOKEN}@ github.com/${{ github.repository }}. wiki.git" wiki
6440
65- COMMENT_BODY="""
41+ - name : Update or add PR comment
42+ env :
43+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44+ PR : ${{ github.event.pull_request.number }}
45+ REPO : ${{ github.repository }}
46+ run : |
47+ set -euo pipefail
48+
49+ PREFIX="https://github.com/${REPO}/wiki/"
50+ BADGE_DIR="wiki/${REPO}"
6651
67- git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/DARMA-tasking/badge-generator.wiki.git wiki
52+ COMMENT=""
6853
69- # List files in the directory and store in an array
70- mapfile -t FILE_ARRAY < <(ls -1 "badge-generator/${REPO}" 2>/dev/null || echo "")
54+ if [ -d "$BADGE_DIR" ]; then
55+ for f in "$BADGE_DIR"/*.svg; do
56+ [ -e "$f" ] || continue
57+ FILE=$(basename "$f")
58+ COMMENT+="\n"
59+ done
60+ fi
7161
72- # Append each file to COMMENT_BODY in the specified format
73- for FILE_NAME in "${FILE_ARRAY[@]}"; do
74- COMMENT_BODY+="![$PREFIX_STRING$FILE_NAME]()\n"
75- done
62+ COMMENT+="<!-- BadgeGeneratorComment -->"
7663
77- # Add identifier for comment tracking
78- COMMENT_BODY+="<!-- BadgeGeneratorComment -->"
64+ # escape newlines for JSON
65+ JSON_BODY=$(printf '%s' "$COMMENT" | jq -Rs .)
7966
80- # Get existing comments
81- COMMENTS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
82- -H "Accept: application/vnd.github.v3+json" \
83- https://api.github.com/repos/$REPO/issues/$PR_NUMBER/comments)
67+ COMMENTS=$(curl -s -H "Authorization: token $GH_TOKEN" \
68+ -H "Accept: application/vnd.github.v3+json" \
69+ "https://api.github.com/repos/${REPO}/issues/${PR}/comments")
8470
85- # Check for existing comment with our identifier
86- COMMENT_ID=$(echo "$COMMENTS" | jq -r '.[] | select(.body | contains("<!-- BadgeGeneratorComment -->")) | .id')
71+ ID=$(echo "$COMMENTS" | jq -r '.[] | select(.body|contains("<!-- BadgeGeneratorComment -->")) | .id')
8772
88- if [ -n "$COMMENT_ID " ]; then
89- # Update existing comment
90- curl -s -H "Authorization: token $GITHUB_TOKEN " \
73+ if [ -n "$ID " ]; then
74+ curl -s -X PATCH \
75+ -H "Authorization: token $GH_TOKEN " \
9176 -H "Accept: application/vnd.github.v3+json" \
92- -X PATCH \
93- -d "{\"body\": \"$COMMENT_BODY\"}" \
94- https://api.github.com/repos/$REPO/issues/comments/$COMMENT_ID
77+ -d "{\"body\":$JSON_BODY}" \
78+ "https://api.github.com/repos/${REPO}/issues/comments/${ID}"
9579 else
96- # Create new comment
97- curl -s -H "Authorization: token $GITHUB_TOKEN " \
80+ curl -s -X POST \
81+ -H "Authorization: token $GH_TOKEN " \
9882 -H "Accept: application/vnd.github.v3+json" \
99- -X POST \
100- -d "{\"body\": \"$COMMENT_BODY\"}" \
101- https://api.github.com/repos/$REPO/issues/$PR_NUMBER/comments
83+ -d "{\"body\":$JSON_BODY}" \
84+ "https://api.github.com/repos/${REPO}/issues/${PR}/comments"
10285 fi
0 commit comments