mirror of
https://github.com/henry4682/linebot_finance.git
synced 2026-05-16 04:41:52 +00:00
feat: linebot
change deploy.yaml
This commit is contained in:
@@ -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)"
|
||||
docker image prune -f
|
||||
Reference in New Issue
Block a user