mirror of
https://github.com/henry4682/linebot_finance.git
synced 2026-05-16 04:41:52 +00:00
change gitea yaml
This commit is contained in:
@@ -8,26 +8,25 @@ jobs:
|
|||||||
redeploy:
|
redeploy:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy
|
# 1. 讓 Runner 把最新程式碼下載到它自己的容器裡
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# 2. 將下載好的程式碼搬移到主機上的運行目錄
|
||||||
|
- name: Sync Files to App Directory
|
||||||
run: |
|
run: |
|
||||||
# 1. 強制讓 Git 信任所有路徑
|
echo "Current directory contains:"
|
||||||
git config --global --add safe.directory "*"
|
ls -la
|
||||||
|
|
||||||
# 2. 進入部署目錄
|
# 直接將當前目錄的所有檔案複製到目標目錄
|
||||||
cd /home/ubuntu/apps/linebot_finance || exit 1
|
# -a 保留屬性, -f 強制覆蓋
|
||||||
|
# 注意:我們不走 git fetch,直接覆蓋檔案
|
||||||
|
cp -rf . /home/ubuntu/apps/linebot_finance/
|
||||||
|
|
||||||
# 3. 確保遠端路徑正確
|
echo "Sync completed. Switching to App directory..."
|
||||||
git remote set-url origin "/opt/1panel/apps/gitea/gitea/data/git/repositories/henry4682/linebot_finance.git"
|
cd /home/ubuntu/apps/linebot_finance
|
||||||
|
|
||||||
# 4. 強制同步 (關鍵:使用 sudo 權限執行,確保能讀取 1Panel 資料夾)
|
# 3. 執行 Docker Compose
|
||||||
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..."
|
echo "Rebuilding and restarting Docker..."
|
||||||
docker compose up -d --build
|
docker compose up -d --build
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user