Surface the real build error when website deploy.sh fails.
Super Admin was only showing "exited with code 1" because the ERR trap never copied the last compiler or module-not-found line from the deploy log. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
20cc0bbd78
commit
40284df880
@@ -28,12 +28,45 @@ write_status() {
|
|||||||
>"$STATUS"
|
>"$STATUS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fail_snippet() {
|
||||||
|
if [[ ! -f "$LOG" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
local chunk snippet=""
|
||||||
|
# Only the current deploy (log is appended across runs).
|
||||||
|
chunk="$(awk 'BEGIN{s=""} /^==== / && /deploy start:/{s=""} {s=s $0 ORS} END{printf "%s", s}' "$LOG")"
|
||||||
|
snippet="$(
|
||||||
|
{ printf '%s' "$chunk" | grep -E "Error:|Type error|Module not found|ELIFECYCLE|npm ERR!" || true; } \
|
||||||
|
| sed 's/\x1b\[[0-9;]*m//g' \
|
||||||
|
| tail -n 4 \
|
||||||
|
| tr '\n' ' ' \
|
||||||
|
| sed 's/[[:space:]]\+/ /g'
|
||||||
|
)"
|
||||||
|
if [[ -z "${snippet// }" ]]; then
|
||||||
|
snippet="$(
|
||||||
|
printf '%s' "$chunk" \
|
||||||
|
| tail -n 12 \
|
||||||
|
| sed 's/\x1b\[[0-9;]*m//g' \
|
||||||
|
| tr '\n' ' ' \
|
||||||
|
| sed 's/[[:space:]]\+/ /g'
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
printf '%s' "$snippet"
|
||||||
|
}
|
||||||
|
|
||||||
echo "==== $(date -u +%Y-%m-%dT%H:%M:%SZ) deploy start: $SLUG ===="
|
echo "==== $(date -u +%Y-%m-%dT%H:%M:%SZ) deploy start: $SLUG ===="
|
||||||
write_status "started" "Deploy running"
|
write_status "started" "Deploy running"
|
||||||
|
|
||||||
cleanup_fail() {
|
cleanup_fail() {
|
||||||
local code=$?
|
local code=$?
|
||||||
write_status "failed" "deploy.sh exited with code $code"
|
trap - ERR
|
||||||
|
local snippet
|
||||||
|
snippet="$(fail_snippet)"
|
||||||
|
if [[ -n "${snippet// }" ]]; then
|
||||||
|
write_status "failed" "exit $code: $snippet"
|
||||||
|
else
|
||||||
|
write_status "failed" "deploy.sh exited with code $code"
|
||||||
|
fi
|
||||||
exit "$code"
|
exit "$code"
|
||||||
}
|
}
|
||||||
trap cleanup_fail ERR
|
trap cleanup_fail ERR
|
||||||
|
|||||||
Reference in New Issue
Block a user