Files
star-erp/.gitea/workflows/deploy.yaml
sky121113 b8a381719b
All checks were successful
Koori-ERP-Sync-Only / sync-update (push) Successful in 1m36s
cicd v10
2025-12-31 15:59:17 +08:00

57 lines
2.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Koori-ERP-Sync-Only
on:
push:
branches:
- main
jobs:
sync-update:
runs-on: ubuntu-latest
steps:
- name: 1. Checkout New Code
uses: actions/checkout@v3
with:
github-server-url: http://192.168.0.103:3000
repository: ${{ gitea.repository }}
- name: 2. Sync Files to Running Container
run: |
# A. 先強制刪除 Runner 空間裡可能存在的舊 .env
rm -f .env
# B. 執行複製
cp .env.example .env
# C. 【Debug 關鍵】在日誌裡印出來看,確定現在 Runner 看到的 .env 長怎樣
echo "--- Current .env Content ---"
cat .env
echo "----------------------------"
docker compose up -d --build --force-recreate
# 這一步最關鍵!它把剛抓下來的新 Code 塞進去「正在跑」的容器
# 它不會刪掉你的 .env因為它是用 tar 覆蓋進去
tar -cf - . | docker exec -i koori-erp-laravel.test-1 tar -xf - -C /var/www/html
- name: 3. Refresh Backend (Only if needed)
run: |
# 執行 Composer (確保你有加新套件的話會抓到)
docker exec -w /var/www/html koori-erp-laravel.test-1 composer install --optimize-autoloader
# 同步資料庫欄位 (如果你有改 Migration 的話)
docker exec koori-erp-laravel.test-1 php artisan migrate --force
- name: 4. Build New React Assets
run: |
# 既然你改了前端,就要在容器內重新跑一次打包
docker exec -w /var/www/html koori-erp-laravel.test-1 npm install
docker exec -w /var/www/html koori-erp-laravel.test-1 npm run build
- name: 5. Final Permission Fix
run: |
# 統一修正權限
docker exec koori-erp-laravel.test-1 chown -R www-data:www-data /var/www/html
docker exec koori-erp-laravel.test-1 chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
- name: 6. Clear Old Cache
run: |
# 讓 Laravel 重新讀取最新的路由與設定
docker exec koori-erp-laravel.test-1 php artisan config:clear
docker exec koori-erp-laravel.test-1 php artisan route:clear