4646 matrix :
4747 dockerfile : ${{ fromJson(needs.get-check-list.outputs.files) }}
4848 fail-fast : false
49+ outputs :
50+ comments : ${{ steps.build-check.outputs.comment_message }}
4951 steps :
5052 - name : Checkout PR branch
5153 uses : actions/checkout@v4
@@ -125,8 +127,22 @@ jobs:
125127 - name : Collect all comment messages
126128 id : collect
127129 run : |
128- echo "raw outputs: ${{ toJson(needs.build-check.comment_message) }}"
129- comments=$(echo '${{ toJson(needs.build-check.comment_message) }}' | jq -r 'to_entries[] | select(.value != null and .value != "") | .value' | sed ':a;N;$!ba;s/\n/\\n/g')
130+ comments=""
131+ echo "raw outputs: ${{ toJson(needs.build-check.outputs.comments) }}"
132+ for result in ${{ toJson(needs.build-check.outputs) }}; do
133+ if [ -n "$result" ] && [ "$result" != "null" ]; then
134+ comments="${comments}\n${result#*:}"
135+ fi
136+ done
137+
138+ # echo "raw outputs: ${{ toJson(needs.build-check.comment_message) }}"
139+ # comments=$(echo '${{ toJson(needs.build-check.comment_message) }}' | jq -r 'to_entries[] | select(.value != null and .value != "") | .value' | sed ':a;N;$!ba;s/\n/\\n/g')
140+
141+ comments=$(echo -e "$comments" | grep -v '^$' | sort | uniq)
142+ if [ -z "$comments" ]; then
143+ echo "No comments to post"
144+ exit 0
145+ fi
130146 echo "all_comments=$comments"
131147 echo "all_comments=$comments" >> $GITHUB_OUTPUT
132148
@@ -144,7 +160,7 @@ jobs:
144160 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
145161 run : |
146162 echo "comment ${all_comments}"
147-
163+ json_body=$(jq -n --arg msg "$all_comments" '{"body": $msg}')
148164 comment_id=$(curl -s \
149165 -H "Authorization: token ${GITHUB_TOKEN}" \
150166 -H "Accept: application/vnd.github.v3+json" \
@@ -156,11 +172,11 @@ jobs:
156172 -H "Authorization: token ${GITHUB_TOKEN}" \
157173 -H "Accept: application/vnd.github.v3+json" \
158174 "https://api.github.com/repos/opea-project/GenAIExamples/issues/${{ github.event.pull_request.number }}/comments" \
159- -d '{"body":"'"$all_comments"'"}'
175+ -d "$json_body"
160176 else
161177 curl -X POST \
162178 -H "Authorization: token ${GITHUB_TOKEN}" \
163179 -H "Accept: application/vnd.github.v3+json" \
164180 "https://api.github.com/repos/opea-project/GenAIExamples/issues/${{ github.event.pull_request.number }}/comments" \
165- -d '{"body":"'"$all_comments"'"}'
181+ -d "$json_body"
166182 fi
0 commit comments