From 1408a235cf4cbf9dae1b7c9946742666156f74a1 Mon Sep 17 00:00:00 2001 From: henry yo Date: Wed, 18 Mar 2026 00:41:15 +0800 Subject: [PATCH] feat: linebot change deploy.yaml --- .gitea/workflows/deploy.yaml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 96c79f2..e780736 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -10,26 +10,14 @@ jobs: steps: - name: Sync and Deploy run: | - echo "Current user: $(whoami)" - echo "Deployment started at: $(date)" + # 1. 進入目錄 (若失敗直接停止) + cd /home/ubuntu/apps/linebot_finance || exit 1 - # 1. 進入專案目錄 - cd /home/ubuntu/apps/linebot_finance || { echo "Directory not found"; exit 1; } - - # 2. 同步代碼 - # 確保 git 知道它在一個安全目錄 (有時 Docker/Runner 權限會卡住) - git config --global --add safe.directory /home/ubuntu/apps/linebot_finance - - echo "Fetching latest code..." + # 2. 強制更新代碼 (避免任何 conflict 導致卡住) + # 注意:這裡假設你已經執行過 git config credential.helper store 讓它記住密碼了 git fetch origin main git reset --hard origin/main - # 3. 重新啟動 Docker 容器 - echo "Restarting Docker Compose..." - # 使用 --remove-orphans 確保清理乾淨 + # 3. 部署與清理 docker compose up -d --build --remove-orphans - - # 4. 清理沒用的鏡像 - docker image prune -f - - echo "Deployment successful at: $(date)" \ No newline at end of file + docker image prune -f \ No newline at end of file