@@ -39,38 +39,14 @@ jobs:
3939 path : cmk.linux.x86-64.pr${{ github.event.pull_request.number }}
4040 if-no-files-found : error
4141
42- - name : Install jq
43- run : sudo apt-get update && sudo apt-get install -y jq
44-
45- - name : Comment on PR with artifact link
42+ - name : Comment on PR with artefact link
4643 if : ${{ github.event_name == 'pull_request' }}
47- env :
48- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
49- PR_NUMBER : ${{ github.event.pull_request.number }}
50- RUN_ID : ${{ github.run_id }}
51- REPO : ${{ github.repository }}
52- run : |
53- COMMENT_BODY="<!-- cmk-build-artifact -->
54- ✅ Build complete for PR #${PR_NUMBER}
55- 🔗 [Download the cmk binary](https://github.com/${REPO}/actions/runs/${RUN_ID})"
56-
57- # Find existing comment ID (if any)
58- comment_id=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" \
59- "https://api.github.com/repos/${REPO}/issues/${PR_NUMBER}/comments" |
60- jq '.[] | select(.user.login == "github-actions[bot]") | select(.body | contains("<!-- cmk-build-artifact -->")) | .id')
61-
62- if [ -n "$comment_id" ]; then
63- echo "📝 Updating existing comment $comment_id"
64- curl -s -X PATCH \
65- -H "Authorization: Bearer ${GITHUB_TOKEN}" \
66- -H "Content-Type: application/json" \
67- -d "$(jq -n --arg body "$COMMENT_BODY" '{body: $body}')" \
68- "https://api.github.com/repos/${REPO}/issues/comments/${comment_id}"
69- else
70- echo "💬 Creating new comment"
71- curl -s -X POST \
72- -H "Authorization: Bearer ${GITHUB_TOKEN}" \
73- -H "Content-Type: application/json" \
74- -d "$(jq -n --arg body "$COMMENT_BODY" '{body: $body}')" \
75- "https://api.github.com/repos/${REPO}/issues/${PR_NUMBER}/comments"
76- fi
44+ uses : peter-evans/create-or-update-comment@v4
45+ with :
46+ token : ${{ secrets.GITHUB_TOKEN }}
47+ issue-number : ${{ github.event.pull_request.number }}
48+ body : |
49+ <!-- cmk-build-artifact -->
50+ ✅ Build complete for PR #${{ github.event.pull_request.number }}
51+ 🔗 [Download the cmk binary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
52+ edit-mode : replace
0 commit comments