Skip to content

Commit 30d934e

Browse files
committed
Refactor release body update to use jq for JSON payload construction
1 parent d394db6 commit 30d934e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

.github/actions/clean-release-notes/action.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,15 @@ runs:
130130
PUBLISH: ${{ inputs.publish }}
131131
run: |
132132
set -euo pipefail
133-
args=(--method PATCH "/repos/${REPO}/releases/${RELEASE_ID}" \
134-
--raw-field "body=@${RUNNER_TEMP}/cleaned.md")
133+
# Build the JSON payload with jq so markdown content (newlines,
134+
# backticks, special chars) is correctly escaped. --rawfile reads
135+
# the cleaned body verbatim into a jq string variable.
135136
if [ "${PUBLISH}" = "true" ]; then
136-
# -F sends typed JSON fields (booleans stay booleans).
137-
args+=(-F draft=false)
137+
payload=$(jq -n --rawfile body "$RUNNER_TEMP/cleaned.md" '{body: $body, draft: false}')
138+
else
139+
payload=$(jq -n --rawfile body "$RUNNER_TEMP/cleaned.md" '{body: $body}')
138140
fi
139-
gh api "${args[@]}" > /dev/null
141+
printf '%s' "$payload" | gh api --method PATCH "/repos/${REPO}/releases/${RELEASE_ID}" --input - > /dev/null
140142
if [ "${PUBLISH}" = "true" ]; then
141143
echo "Release ${RELEASE_ID} in ${REPO}: body patched + published."
142144
else

0 commit comments

Comments
 (0)