Skip to content

Commit 177143b

Browse files
dsarnoclaude
andcommitted
Sanitize Discord webhook URL and make changelog post non-fatal
The first real release post failed with `curl: (3) URL rejected: Malformed input to a URL function` — the DISCORD_CHANGELOG_WEBHOOK secret carries a trailing newline (captured by `gh secret set` when the value is pasted/piped with one), which curl rejects as a malformed URL. - Strip all whitespace from the webhook value before use. A webhook URL has no internal whitespace, so this is safe and repairs the contaminated secret without needing it re-set. - Make the post non-fatal: the release already shipped before this step, so a Discord failure now logs a ::warning:: annotation and exits 0 instead of turning a successful release red. Also adds curl --retry for transient network blips. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5d22c92 commit 177143b

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ jobs:
182182
DISCORD_WEBHOOK: ${{ secrets.DISCORD_CHANGELOG_WEBHOOK }}
183183
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184184
run: |
185+
# Strip any whitespace/newlines from the secret. `gh secret set`
186+
# captures a trailing newline if the value was piped/pasted with
187+
# one, which makes curl reject the URL with "(3) Malformed input to
188+
# a URL function". A webhook URL contains no internal whitespace, so
189+
# stripping all whitespace is safe and fixes contaminated secrets
190+
# regardless of how they were set.
191+
DISCORD_WEBHOOK=$(printf '%s' "$DISCORD_WEBHOOK" | tr -d '[:space:]')
185192
if [ -z "$DISCORD_WEBHOOK" ]; then
186193
echo "DISCORD_CHANGELOG_WEBHOOK not set — skipping changelog post."
187194
exit 0
@@ -208,6 +215,12 @@ jobs:
208215
color: 5793266
209216
} ]
210217
}')
211-
curl -fsS -H "Content-Type: application/json" \
212-
-X POST -d "$payload" "$DISCORD_WEBHOOK"
213-
echo "Posted changelog for $tag to Discord."
218+
# The changelog post is non-essential: the release already shipped
219+
# before this step. A Discord outage or a bad webhook must not turn
220+
# a successful release red — log a warning annotation and exit 0.
221+
if curl -fsS --retry 3 --retry-delay 2 -H "Content-Type: application/json" \
222+
-X POST -d "$payload" "$DISCORD_WEBHOOK"; then
223+
echo "Posted changelog for $tag to Discord."
224+
else
225+
echo "::warning::Discord changelog post for $tag failed (release itself is unaffected)."
226+
fi

0 commit comments

Comments
 (0)