mirror of
https://github.com/henry4682/linebot_finance.git
synced 2026-05-16 04:41:52 +00:00
35 lines
1.1 KiB
YAML
35 lines
1.1 KiB
YAML
name: Oracle-Deploy
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
redeploy:
|
|
runs-on: ubuntu-latest # 改成這個,對應你的 Runner 標籤
|
|
steps:
|
|
- name: Sync and Deploy
|
|
run: |
|
|
echo "Current user: $(whoami)"
|
|
echo "Deployment started at: $(date)"
|
|
|
|
# 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..."
|
|
git fetch origin main
|
|
git reset --hard origin/main
|
|
|
|
# 3. 重新啟動 Docker 容器
|
|
echo "Restarting Docker Compose..."
|
|
# 使用 --remove-orphans 確保清理乾淨
|
|
docker compose up -d --build --remove-orphans
|
|
|
|
# 4. 清理沒用的鏡像
|
|
docker image prune -f
|
|
|
|
echo "Deployment successful at: $(date)" |