Skip to content

Commit 7555ab0

Browse files
fix(apply-repo-settings): surface full API error body via step summary (#63)
Co-authored-by: nsheaps <nsheaps@gmail.com>
1 parent 4865821 commit 7555ab0

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

‎.github/actions/apply-repo-settings/action.sh‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,27 @@ api() {
6666
rm -f "$resp_file"
6767

6868
if [[ "$http_code" -lt 200 || "$http_code" -ge 300 ]]; then
69-
echo "::error::API $method $path failed (HTTP $http_code): $resp_body" >&2
69+
# Single-line annotation: GitHub truncates at the first newline, which on a
70+
# JSON body lands at the first `{` — losing every useful field. Compact via
71+
# jq when possible so the annotation carries the full message.
72+
local compact_body="$resp_body"
73+
if command -v jq >/dev/null 2>&1; then
74+
compact_body=$(echo "$resp_body" | jq -c . 2>/dev/null) || compact_body="$resp_body"
75+
fi
76+
echo "::error::API $method $path failed (HTTP $http_code): $compact_body" >&2
77+
# Also surface the *pretty* body in the step summary (readable in the
78+
# job page AND via /actions/jobs/{id} → output.summary in the API).
79+
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
80+
{
81+
echo "### API failure: $method $path"
82+
echo
83+
echo "**HTTP $http_code**"
84+
echo
85+
echo '```json'
86+
echo "$resp_body"
87+
echo '```'
88+
} >> "$GITHUB_STEP_SUMMARY"
89+
fi
7090
return 1
7191
fi
7292

0 commit comments

Comments
 (0)