Files
ai-code-review/entrypoint.sh
T

26 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# ============================================================
# 用途:Docker action 的進入點(entrypoint),負責啟動 Node.js
# 撰寫的 AI code review 執行器(review runner)。
# 此 script 為容器啟動時執行的第一支程式。
# 更新日期:2026/06/26 11:34:46
# ============================================================
# set -e:開啟「遇到任何指令回傳非零(失敗)即立刻中止 script」模式。
# 為什麼:避免前面步驟失敗卻仍繼續往下執行,確保 review runner 在
# 乾淨且可預期的狀態下啟動。
# 副作用:之後任一指令失敗會讓整支 entrypoint(連同容器)以非零碼結束。
set -e
# echo:印出啟動提示訊息到 stdout,方便在 CI/容器 log 中辨識啟動點。
# 為什麼:提供可觀測性,確認 entrypoint 已被執行。
# 副作用:僅輸出文字,無其他影響。
echo "🚀 AI Code Review Action 啟動"
# exec node /app/main.js:用 node 進程「取代」目前的 shell 進程來執行
# 主程式 main.jsAI code review 的實際邏輯入口)。
# 為什麼:使用 exec 而非直接呼叫,可讓 node 成為 PID 1,正確接收
# 容器的訊號(如 SIGTERM),達成優雅關閉並避免殭屍 shell。
# 副作用:此行之後的任何指令都不會被執行;node 的結束碼即為容器結束碼。
exec node /app/main.js