Files
linebot_finance/.gitea/workflows/deploy.yaml
henry4682 b09f41decc
All checks were successful
Oracle-Deploy / redeploy (push) Successful in 2m28s
change deploy.yaml
2026-03-23 15:06:47 +08:00

43 lines
1.5 KiB
YAML

name: Oracle-Deploy
on:
push:
branches:
- main
jobs:
redeploy:
runs-on: self-hosted # 你的 Runner 已經有這個標籤了,沒問題
steps:
- name: Preparation and Git Sync
run: |
# 建立父目錄
mkdir -p /home/ubuntu/apps/linebot_finance
cd /home/ubuntu/apps/linebot_finance
# 核心邏輯:如果不是 Git 儲存庫,就清空它
if [ ! -d ".git" ]; then
echo "⚠️ 目錄已存在但非 Git 儲存庫,正在清空以重新初始化..."
rm -rf ..?* .[!.]* * # 刪除隱藏檔與一般檔案
git clone http://localhost:3000/henry4682/linebot_finance.git .
else
echo "🔄 正在更新現有儲存庫..."
git fetch origin main
git reset --hard origin/main
fi
- name: Create .env file from Secrets
run: |
# 直接指定絕對路徑寫入,最保險
echo '${{ secrets.ENV_FILE }}' > /home/ubuntu/apps/linebot_finance/.env
chmod 600 /home/ubuntu/apps/linebot_finance/.env
echo ".env 檔案已由 Secrets 產生 🚀"
- name: Docker Build and Deploy
run: |
cd /home/ubuntu/apps/linebot_finance
# 執行 Docker Compose
docker compose up -d --build --remove-orphans
# 清理過期鏡像節省 Oracle 空間
docker image prune -f
echo "✅ 部署完成!"