ci: stream buildx logs with tail heartbeat

This commit is contained in:
2026-05-10 12:53:24 +08:00
parent c5346940e7
commit d69c7d015e
Vendored
+8 -36
View File
@@ -87,29 +87,15 @@ pipeline {
: > "\$log_file"
"\$@" >"\$log_file" 2>&1 &
cmd_pid=\$!
last_line=0
cmd_status=0
tail --pid="\$cmd_pid" -n +1 -f "\$log_file" &
tail_pid=\$!
while kill -0 "\$cmd_pid" >/dev/null 2>&1; do
if [ -f "\$log_file" ]; then
total_lines=\$(wc -l < "\$log_file" || echo 0)
else
total_lines=0
fi
if [ "\$total_lines" -gt "\$last_line" ]; then
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
last_line=\$total_lines
else
echo "[heartbeat] API multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
fi
echo "[heartbeat] API multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
sleep 20
done
wait "\$cmd_pid" || cmd_status=\$?
if [ -f "\$log_file" ]; then
total_lines=\$(wc -l < "\$log_file" || echo 0)
if [ "\$total_lines" -gt "\$last_line" ]; then
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
fi
fi
wait "\$tail_pid" >/dev/null 2>&1 || true
if [ "\$cmd_status" -ne 0 ]; then
echo "[heartbeat] API multi-arch build failed with exit code \$cmd_status"
fi
@@ -163,29 +149,15 @@ pipeline {
: > "\$log_file"
"\$@" >"\$log_file" 2>&1 &
cmd_pid=\$!
last_line=0
cmd_status=0
tail --pid="\$cmd_pid" -n +1 -f "\$log_file" &
tail_pid=\$!
while kill -0 "\$cmd_pid" >/dev/null 2>&1; do
if [ -f "\$log_file" ]; then
total_lines=\$(wc -l < "\$log_file" || echo 0)
else
total_lines=0
fi
if [ "\$total_lines" -gt "\$last_line" ]; then
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
last_line=\$total_lines
else
echo "[heartbeat] Web multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
fi
echo "[heartbeat] Web multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
sleep 20
done
wait "\$cmd_pid" || cmd_status=\$?
if [ -f "\$log_file" ]; then
total_lines=\$(wc -l < "\$log_file" || echo 0)
if [ "\$total_lines" -gt "\$last_line" ]; then
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
fi
fi
wait "\$tail_pid" >/dev/null 2>&1 || true
if [ "\$cmd_status" -ne 0 ]; then
echo "[heartbeat] Web multi-arch build failed with exit code \$cmd_status"
fi