JB
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped

This commit is contained in:
2026-01-06 10:23:00 +08:00
parent 04e4ec0dca
commit 6631f64e4b

View File

@@ -18,48 +18,18 @@ jobs:
github-server-url: http://192.168.0.103:3000 github-server-url: http://192.168.0.103:3000
repository: ${{ github.repository }} repository: ${{ github.repository }}
# - name: Deploy to 103 Demo - name: Deploy to 103 Demo
# run: |
# cp .env.example .env
# # 設定 Demo 專用的 Key
# sed -i "s|APP_KEY=.*|APP_KEY=${{ secrets.APP_KEY }}|g" .env
# docker compose up -d --build --wait
# # 同步檔案到容器內
# tar --exclude='.git' --exclude='node_modules' --exclude='vendor' -cf - . | docker exec -i koori-erp-laravel tar -xf - -C /var/www/html
# docker exec -u 1000:1000 koori-erp-laravel sh -c "composer install && npm install && npm run build && php artisan migrate --force && php artisan optimize:clear"
- name: 2. Sync Files to Running Container
run: | run: |
# A. 執行複製
cp .env.example .env cp .env.example .env
# 設定 Demo 專用的 Key
sed -i "s|APP_KEY=.*|APP_KEY=${{ secrets.APP_KEY }}|g" .env sed -i "s|APP_KEY=.*|APP_KEY=${{ secrets.APP_KEY }}|g" .env
# B. 確保容器環境是最新的 docker compose up -d --build --wait
# --wait 會確保容器真的跑起來了才執行下一步 # 同步檔案到容器內
docker compose up -d --build --force-recreate --wait tar --exclude='.git' --exclude='node_modules' --exclude='vendor' -cf - . | docker exec -i koori-erp-laravel tar -xf - -C /var/www/html
# C. 執行精簡化複製 (關鍵優化!)
# 排除 .git, node_modules, vendor 這三大黑洞
tar --exclude='.git' \
--exclude='node_modules' \
--exclude='vendor' \
-cf - . | docker exec -i koori-erp-laravel tar -xf - -C /var/www/html
docker exec koori-erp-laravel chown -R 1000:1000 /var/www/html docker exec koori-erp-laravel chown -R 1000:1000 /var/www/html
docker exec -u 1000:1000 -w /var/www/html koori-erp-laravel sh -c "composer install && npm install && npm run build && php artisan migrate --force && php artisan optimize:clear"
- name: 3. Backend & Frontend Build
run: |
docker exec -u 1000:1000 -w /var/www/html koori-erp-laravel sh -c "
composer install --optimize-autoloader &&
npm install &&
npm run build &&
php artisan migrate --force &&
php artisan optimize:clear
"
- name: 4. Final Permission Fix
run: |
# 統一修正權限
docker exec koori-erp-laravel chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache docker exec koori-erp-laravel chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
# --- 2. 正式環境部署 (erp.koori.tw:2224) --- # --- 2. 正式環境部署 (erp.koori.tw:2224) ---
# deploy-production: # deploy-production:
# if: github.ref == 'refs/heads/main' # if: github.ref == 'refs/heads/main'