From 8745aedb8e7ecfd41c191c4bc8837bf7c7bf294a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 3 May 2026 06:39:54 +0000 Subject: [PATCH] fix: use jq to safely build Discord webhook JSON payload Agent-Logs-Url: https://github.com/th30d4y/0Commits/sessions/67b9076a-162b-4872-99ff-49ffe07dd37c Co-authored-by: 0x5t4l1n <161853795+0x5t4l1n@users.noreply.github.com> --- .github/workflows/discord-notify.yml | 39 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/discord-notify.yml b/.github/workflows/discord-notify.yml index 1a5ecdd..9782a48 100644 --- a/.github/workflows/discord-notify.yml +++ b/.github/workflows/discord-notify.yml @@ -13,27 +13,36 @@ jobs: - name: Send Discord notification env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + AUTHOR: ${{ github.event.head_commit.author.name }} run: | COMMIT_SHA="${{ github.sha }}" SHORT_SHA="${COMMIT_SHA:0:7}" - COMMIT_MESSAGE="${{ github.event.head_commit.message }}" - AUTHOR="${{ github.event.head_commit.author.name }}" BRANCH="${{ github.ref_name }}" REPO="${{ github.repository }}" COMMIT_URL="https://github.com/${REPO}/commit/${COMMIT_SHA}" - curl -s -X POST "$DISCORD_WEBHOOK" \ - -H "Content-Type: application/json" \ - -d "{ - \"embeds\": [{ - \"title\": \"New Commit in \`${REPO}\`\", - \"url\": \"${COMMIT_URL}\", - \"color\": 5814783, - \"fields\": [ - { \"name\": \"Author\", \"value\": \"${AUTHOR}\", \"inline\": true }, - { \"name\": \"Branch\", \"value\": \"\`${BRANCH}\`\", \"inline\": true }, - { \"name\": \"Commit\", \"value\": \"[\`${SHORT_SHA}\`](${COMMIT_URL})\", \"inline\": true }, - { \"name\": \"Message\", \"value\": \"${COMMIT_MESSAGE}\" } + PAYLOAD=$(jq -n \ + --arg title "New Commit in \`${REPO}\`" \ + --arg url "$COMMIT_URL" \ + --arg author "$AUTHOR" \ + --arg branch "\`${BRANCH}\`" \ + --arg commit "[\`${SHORT_SHA}\`](${COMMIT_URL})" \ + --arg message "$COMMIT_MESSAGE" \ + '{ + embeds: [{ + title: $title, + url: $url, + color: 5814783, + fields: [ + {name: "Author", value: $author, inline: true}, + {name: "Branch", value: $branch, inline: true}, + {name: "Commit", value: $commit, inline: true}, + {name: "Message", value: $message} ] }] - }" + }') + + curl -sf -X POST "$DISCORD_WEBHOOK" \ + -H "Content-Type: application/json" \ + -d "$PAYLOAD"