mirror of
https://github.com/henry4682/linebot_finance.git
synced 2026-05-16 04:41:52 +00:00
34 lines
1.1 KiB
YAML
34 lines
1.1 KiB
YAML
name: Oracle-Deploy
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
redeploy:
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Deploy
|
|
run: |
|
|
# 1. 強制讓 Git 信任所有路徑
|
|
git config --global --add safe.directory "*"
|
|
|
|
# 2. 進入部署目錄
|
|
cd /home/ubuntu/apps/linebot_finance || exit 1
|
|
|
|
# 3. 確保遠端路徑正確
|
|
git remote set-url origin "/opt/1panel/apps/gitea/gitea/data/git/repositories/henry4682/linebot_finance.git"
|
|
|
|
# 4. 強制同步 (關鍵:使用 sudo 權限執行,確保能讀取 1Panel 資料夾)
|
|
echo "Syncing code using sudo to overcome directory permissions..."
|
|
sudo git fetch --all
|
|
sudo git reset --hard origin/main
|
|
|
|
# 5. 確保檔案擁有者回到 ubuntu
|
|
sudo chown -R ubuntu:ubuntu /home/ubuntu/apps/linebot_finance
|
|
|
|
# 6. 重啟 Docker
|
|
echo "Rebuilding and restarting Docker..."
|
|
docker compose up -d --build
|
|
|
|
echo "Deployment successful!" |