From 29a7d810846179dcacf497534b5d8e8b20dc0328 Mon Sep 17 00:00:00 2001 From: saltydk Date: Wed, 6 Mar 2024 16:18:45 +0100 Subject: [PATCH] GHA: update build-pr --- .github/workflows/build-pr.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 3ac1ac170..1c07ee1a3 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -73,6 +73,8 @@ jobs: REPO: ${{ github.repository }} - name: Comment PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | PR_NUMBER=${{ github.event.inputs.pr_number }} PREVIEW_URL=${{ needs.build.outputs.url }} @@ -87,24 +89,19 @@ jobs: STATUS_MESSAGE="Build failed!" fi - COMMENT_BODY="

Deploying with  Cloudflare Pages  Cloudflare Pages

- - - -
Status: $STATUS_EMOJI  $STATUS_MESSAGE
Preview URL: - $PREVIEW_URL -
Branch Preview URL: - $BRANCH_PREVIEW_URL -
" + COMMENT_BODY="Deploying with ⚡ Cloudflare Pages
Status: $STATUS_EMOJI  $STATUS_MESSAGE
Preview URL:$PREVIEW_URL
Branch Preview URL:$BRANCH_PREVIEW_URL
" + + # Convert COMMENT_BODY to JSON string and escape double quotes + ESCAPED_BODY=$(echo "$COMMENT_BODY" | jq -aRs .) COMMENTS_URL="https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" + curl -H "Authorization: token $GITHUB_TOKEN" \ -H "Accept: application/vnd.github+json" \ -X POST \ - -d "{\"body\": \"$COMMENT_BODY\"}" \ + -d "{\"body\": $ESCAPED_BODY }" \ $COMMENTS_URL - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + webhook: name: 'webhook'