diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11101472..77127393 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -246,6 +246,7 @@ jobs: shell: bash env: DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + COMMIT_MSG: ${{ github.event.head_commit.message }} run: | if [ -z "$DISCORD_WEBHOOK_URL" ]; then echo "DISCORD_WEBHOOK_URL not configured, skipping." @@ -283,6 +284,14 @@ jobs: SHA="${{ github.sha }}" SHORT_SHA="${SHA:0:7}" + # Discord caps embed field values at 1024 chars. Use only the commit + # subject (first line) and truncate it so the payload is never rejected + # with HTTP 400 on long, multi-line (e.g. squash-merged) messages. + COMMIT_SUBJECT=$(printf '%s' "$COMMIT_MSG" | head -n 1) + if [ "${#COMMIT_SUBJECT}" -gt 256 ]; then + COMMIT_SUBJECT="${COMMIT_SUBJECT:0:253}..." + fi + PAYLOAD=$(jq -n \ --arg title "vMenu (v${DISPLAY_VERSION})" \ --arg desc "$STATUS_TEXT" \ @@ -294,7 +303,7 @@ jobs: --arg link_url "$LINK_URL" \ --arg short_sha "$SHORT_SHA" \ --arg commit_url "https://github.com/${{ github.repository }}/commit/${{ github.sha }}" \ - --arg commit_msg "${{ github.event.head_commit.message }}" \ + --arg commit_msg "$COMMIT_SUBJECT" \ '{ embeds: [{ title: $title,