Include log tail in release failure notifications

This commit is contained in:
Ryan Hughes
2026-06-04 19:36:05 -04:00
parent b4617fc6a9
commit 7410dd87af
2 changed files with 31 additions and 0 deletions
+2
View File
@@ -40,6 +40,8 @@ if [[ -n "$LOG_MIRROR" ]]; then
else
LOG_FILE="$LOG_DIR/repo_${TIMESTAMP}.log"
fi
export LOG_FILE
export OMARCHY_LOG_FILE="$LOG_FILE"
# Show usage
show_usage() {
+29
View File
@@ -19,15 +19,44 @@ notify_basecamp() {
"$BASECAMP_CHATBOT_URL" 2>/dev/null || true
}
basecamp_html_escape() {
sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g'
}
basecamp_strip_ansi() {
sed -E $'s/\x1B\\[[0-9;?]*[ -/]*[@-~]//g'
}
basecamp_format_log_tail_html() {
local log_file="$1"
local lines="${2:-25}"
[[ -n "$log_file" && -f "$log_file" ]] || return 0
tail -n "$lines" "$log_file" 2>/dev/null |
tr -d '\r' |
basecamp_strip_ansi |
basecamp_html_escape |
sed ':a;N;$!ba;s/\n/<br>/g'
}
notify_error() {
local title="$1"
local details="${2:-}"
local log_file="${OMARCHY_LOG_FILE:-${LOG_FILE:-}}"
local log_tail_lines="${BASECAMP_LOG_TAIL_LINES:-25}"
local log_tail=""
local content="🔴 <strong>${title}</strong>"
if [[ -n "$details" ]]; then
content+="<br>${details}"
fi
log_tail=$(basecamp_format_log_tail_html "$log_file" "$log_tail_lines")
if [[ -n "$log_tail" ]]; then
content+="<br><br><strong>Last ${log_tail_lines} log lines:</strong><br><code>${log_tail}</code>"
fi
notify_basecamp "$content"
}