Files
clean-old-release/entrypoint.sh
T
JefferyandClaude Fable 5 597fa4119b
docker-actions/template: CI / BUILD (pull_request) Successful in 5s
feat: 實作 Clean Old Release action
- 依建立時間將 release 分為正式版與 beta 版(tag 含 beta),各自保留最新指定筆數(keep_count 預設 5、keep_count_beta 預設 10),其餘舊 release 連同對應 git tag 一併刪除
- Node.js 主程式置於 src/(index.js 主流程、logger.js 統一訊息格式 [yyyy/MM/dd HH:mm:ss][階段][等級]: 訊息)
- 多階段建置 dockerfile(NODE_VERSION=latest / NODE_RUNTIME=slim),entrypoint.sh 輸出啟動訊息後 exec 主程式
- 補齊全部 JSDoc 與指令檔逐行註解,重建 readme.md
- 移除範本的 .gitea/scoped_workflows/ci.yaml

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 08:38:21 +08:00

26 lines
1.7 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
# ============================================================================
# 用途:Gitea docker action「Clean Old Release」的容器入口腳本;
# 容器啟動時由 Docker ENTRYPOINT 呼叫,先輸出啟動訊息,
# 再以 exec 啟動 node 主程式 /action/src/index.js 執行清理舊 release 的主要邏輯。
# 更新時間:2026/07/16 14:15:34
# ============================================================================
# 啟用「任一指令失敗即中止」模式:後續任何指令回傳非零 exit code 時立即結束腳本,
# 避免在啟動階段發生錯誤後仍繼續執行,導致以錯誤狀態啟動主程式
set -e
# 輸出啟動訊息第 1 行:action 名稱,供 CI log 辨識目前執行的 action(此檔由 code-action-docker 產生)
echo "[2026/07/16 14:09:54][啟動][INF]: ActionClean Old Release"
# 輸出啟動訊息第 2 行:action 用途摘要,說明會依建立時間分類並刪除舊 release 與對應 git tag(具刪除副作用,由 node 主程式實際執行)
echo "[2026/07/16 14:09:54][啟動][INF]: 用途:依建立時間將 release 分為正式版與 beta 版,各自保留最新指定筆數,其餘舊 release 連同對應 git tag 一併刪除。"
# 輸出啟動訊息第 3 行:此入口腳本的產生/更新時間,方便追蹤映像檔內腳本版本
echo "[2026/07/16 14:09:54][啟動][INF]: 更新時間:2026/07/16 14:09:54"
# 以 exec 啟動 node 主程式:讓 node 直接取代目前 shell 成為 PID 1
# 正確接收容器停止訊號(SIGTERM 等)並回傳真實 exit code
# "$@" 將容器啟動時傳入的所有參數原封不動轉交給 /action/src/index.js
exec node /action/src/index.js "$@"