Files
calculate-next-version/entrypoint.sh
T
JefferyandClaude Fable 5 1773c646d5
docker-actions/template: CI / BUILD (pull_request) Successful in 4s
refactor: 統一日誌格式為 [階段][等級][時間] 並補齊指令檔文件與 README
- logger.js format() 組字順序改為階段在前、等級居中、時間在後(Asia/Taipei)
- entrypoint.sh 啟動訊息改用新格式並更新標頭時間
- action.yml 新增用途/更新時間標頭與逐行繁中註解,設定值不變
- dockerfile 檔名維持小寫並與 action.yml 的 image 引用一致
- 新增 src/logger.js、src/version.js 模組與完整 JSDoc;重建 README.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 09:30:44 +08:00

35 lines
2.4 KiB
Bash
Executable File
Raw Permalink 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/sh
# ============================================================================
# 用途:Calculate Next VersionDocker container action)的容器進入點。
# 由 action.yml 的 runs.entrypoint 指定,容器啟動時先輸出統一格式的
# 啟動訊息,再以 exec 交棒給 node 主程式 /action/src/index.js 計算下一版號。
# 更新時間:2026/07/16 09:16:42
# ============================================================================
# 開啟「任一指令失敗即中止」模式:任何指令回傳非 0 就立刻結束腳本,
# 避免在錯誤狀態下繼續執行後續步驟,讓 action 失敗能正確反映在 job 結果上
set -e
# action 啟動訊息:名稱/用途/更新時間(此檔由 code-action-docker 產生)
# 依正規化格式 [階段][等級][時間]: 訊息 輸出(階段在前、等級居中、時間在後),
# 讓 workflow log 可以清楚看出 action 名稱與此次啟動的入口
# 需人工確認:訊息中時間為產生檔案時寫死的固定字串,非執行當下時間;
# 若期望顯示實際執行時間需另行調整(此處不修改邏輯)
echo "[啟動][INF][2026/07/16 09:16:42]: ActionCalculate Next Version"
# 啟動訊息第二行:說明此 action 的用途(與 action.yml 的 description 一致),
# 讓使用者在 log 中即可了解版號計算規則(is_beta 分流、各號碼滿 9 進位)
echo "[啟動][INF][2026/07/16 09:16:42]: 用途:從 git tag 取得最新版號,依 is_beta 計算下一個正式版或 beta 版號(各號碼滿 9 進位)並輸出為 value。"
# 啟動訊息第三行:標示此 entrypoint 的更新時間,方便追溯部署的版本
echo "[啟動][INF][2026/07/16 09:16:42]: 更新時間:2026/07/16 09:16:42"
# 啟動 node 主程式(以 exec 取代 shell,正確處理訊號與 exit code):
# - exec 讓 node 直接成為 PID 1 的接班程序,SIGTERM 等訊號可直達 node
# 且 node 的 exit code 會原封不動成為容器(即 action step)的結束碼
# - "$@" 將容器收到的所有引數原樣轉交給主程式(雖然本 action 實際以
# INPUT_IS_BETA 等環境變數傳遞輸入,仍保留引數轉發以維持彈性)
# - 主程式副作用:讀取 GITHUB_WORKSPACE 的 git tag、設定 git safe.directory、
# 並將計算結果 value 寫入 GITHUB_OUTPUT
exec node /action/src/index.js "$@"