Compare commits

...

6 Commits

Author SHA1 Message Date
6631f64e4b JB
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
2026-01-06 10:23:00 +08:00
04e4ec0dca ddd
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Successful in 1m11s
2026-01-06 10:19:18 +08:00
5dacae85d6 tetet
Some checks failed
Koori-ERP-Deploy-System / deploy-demo (push) Failing after 16s
2026-01-06 10:17:17 +08:00
ab2d41720a test2
Some checks failed
Koori-ERP-Deploy-System / deploy-demo (push) Failing after 14s
2026-01-06 10:14:26 +08:00
e5715b7274 test1
Some checks failed
Koori-ERP-Deploy-System / deploy-demo (push) Failing after 28s
2026-01-06 10:09:46 +08:00
c40e331f2b demo
All checks were successful
Koori-ERP-Demo-Deploy / sync-update (push) Successful in 1m7s
2026-01-05 23:50:51 +08:00
3 changed files with 116 additions and 195 deletions

View File

@@ -1,60 +0,0 @@
name: Koori-ERP-Demo-Deploy
on:
push:
branches:
- demo
jobs:
sync-update:
runs-on: demo-server
steps:
# - name: 1. Checkout New Code
# uses: actions/checkout@v3
# with:
# github-server-url: http://192.168.0.103:3000
# repository: ${{ gitea.repository }}
- name: 1. Checkout New Code
run: |
# 進入工作目錄並直接用 git 抓 code完全不需要 Node
rm -rf ./*
git clone -b demo http://server:3000/${{ gitea.repository }}.git .
- name: 2. Sync Files to Running Container
run: |
# A. 執行複製
cp .env.example .env
sed -i "s|APP_KEY=.*|APP_KEY=${{ secrets.APP_KEY }}|g" .env
# B. 確保容器環境是最新的
# --wait 會確保容器真的跑起來了才執行下一步
docker compose -p koori-erp up -d --build --force-recreate --wait
# C. 執行精簡化複製 (關鍵優化!)
# 排除 .git, node_modules, vendor 這三大黑洞
tar --exclude='.git' \
--exclude='node_modules' \
--exclude='vendor' \
-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 1000:1000 /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 view:clear
docker exec koori-erp-laravel.test-1 php artisan config:clear
docker exec koori-erp-laravel.test-1 php artisan route:clear

View File

@@ -0,0 +1,54 @@
# name: Koori-ERP-Demo-Deploy
# on:
# push:
# branches:
# - demo
# 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: 1. Checkout New Code
# # run: |
# # # 進入工作目錄並直接用 git 抓 code完全不需要 Node
# # rm -rf ./*
# # git clone -b main http://server:3000/${{ gitea.repository }}.git .
# - name: 2. Sync Files to Running Container
# run: |
# # A. 執行複製
# cp .env.example .env
# sed -i "s|APP_KEY=.*|APP_KEY=${{ secrets.APP_KEY }}|g" .env
# # B. 確保容器環境是最新的
# # --wait 會確保容器真的跑起來了才執行下一步
# docker compose up -d --build --force-recreate --wait
# # 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
# - 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

View File

@@ -1,151 +1,78 @@
# name: Koori-ERP-Demo-Deploy
# on:
# push:
# branches:
# - main
name: Koori-ERP-Deploy-System
# jobs:
# sync-update:
# runs-on: demo-server
# steps:
# # - name: 1. Checkout New Code
# # uses: actions/checkout@v3
# # with:
# # github-server-url: http://192.168.0.103:3000
# # repository: ${{ gitea.repository }}
# - name: 1. Checkout New Code
# run: |
# # 進入工作目錄並直接用 git 抓 code完全不需要 Node
# rm -rf ./*
# git clone -b main http://server:3000/${{ gitea.repository }}.git .
# - name: 2. Sync Files & Environment
# run: |
# # 建立 .env
# cp .env.example .env
# sed -i "s|APP_KEY=.*|APP_KEY=${{ secrets.APP_KEY }}|g" .env
# # 啟動環境
# docker compose up -d --build --force-recreate
# # A. 同步檔案 (包含 .env)
# tar --exclude='.git' --exclude='node_modules' --exclude='vendor' -cf - . | docker exec -i koori-erp-laravel tar -xf - -C /var/www/html
# - name: 3. Backend & Frontend Build
# run: |
# # 使用一個 exec 區塊跑完編譯,減少 SSH/Exec 連線開銷
# docker exec -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: |
# # 這裡用 1000:1000 是因為你 docker-compose 裡設定了 UID/GID
# docker exec koori-erp-laravel chown -R 1000:1000 /var/www/html
# docker exec koori-erp-laravel chmod -R 775 /var/www/html/storage
# - name: 5. restart container
# run: |
# docker restart koori-erp-laravel
# name: Koori-ERP-Demo-Deploy
# on:
# push:
# branches:
# - main
# jobs:
# sync-update:
# runs-on: demo-server
# steps:
# - name: 1. Checkout New Code
# run: |
# rm -rf ./*
# git clone -b main http://server:3000/${{ gitea.repository }}.git .
# - name: 2. Stop Container First
# run: |
# # 先停止容器
# docker compose down || true
# - name: 3. Prepare Environment
# run: |
# # 建立 .env在宿主機
# cp .env.example .env
# sed -i "s|APP_KEY=.*|APP_KEY=${{ secrets.APP_KEY }}|g" .env
# - name: 4. Start Container (Files Already Ready)
# run: |
# # 啟動容器(檔案已經準備好,透過 volume 自動掛載)
# 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
# - name: 5. Backend & Frontend Build
# run: |
# docker exec -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: 6. Final Permission Fix
# run: |
# docker exec koori-erp-laravel chown -R 1000:1000 /var/www/html
# docker exec koori-erp-laravel chmod -R 775 /var/www/html/storage
name: Koori-ERP-Demo-Deploy
on:
push:
branches:
- demo
- main
jobs:
sync-update:
# --- 1. Demo 環境部署 (103 本機) ---
deploy-demo:
if: github.ref == 'refs/heads/demo'
runs-on: ubuntu-latest
steps:
- name: 1. Checkout New Code
- name: Checkout Code
uses: actions/checkout@v3
with:
github-server-url: http://192.168.0.103:3000
repository: ${{ gitea.repository }}
# - name: 1. Checkout New Code
# run: |
# # 進入工作目錄並直接用 git 抓 code完全不需要 Node
# rm -rf ./*
# git clone -b main http://server:3000/${{ gitea.repository }}.git .
github-server-url: http://192.168.0.103:3000
repository: ${{ github.repository }}
- name: 2. Sync Files to Running Container
run: |
# A. 執行複製
- name: Deploy to 103 Demo
run: |
cp .env.example .env
# 設定 Demo 專用的 Key
sed -i "s|APP_KEY=.*|APP_KEY=${{ secrets.APP_KEY }}|g" .env
# B. 確保容器環境是最新的
# --wait 會確保容器真的跑起來了才執行下一步
docker compose up -d --build --force-recreate --wait
# 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 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 koori-erp-laravel chown -R 1000:1000 /var/www/html
- 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 -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"
docker exec koori-erp-laravel chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
# --- 2. 正式環境部署 (erp.koori.tw:2224) ---
# deploy-production:
# if: github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v3
# # 使用 rsync 透過 2224 Port 推送代碼
# - name: Push Code to Production
# run: |
# # 注意:這裡的 -e 指定了 ssh port 2224
# rsync -avz --delete \
# --exclude='.git' \
# --exclude='node_modules' \
# --exclude='vendor' \
# -e "ssh -p 2224 -o StrictHostKeyChecking=no" \
# ./ root@erp.koori.tw:/var/www/koori-erp-prod/
# # 遠端執行 Docker 指令
# - name: Remote Docker Commands
# uses: appleboy/ssh-action@master
# with:
# host: erp.koori.tw
# port: 2224 # <--- 這裡指定了 2224 Port
# username: root
# key: ${{ secrets.PROD_SSH_KEY }}
# script: |
# cd /var/www/koori-erp-prod
# # 1. 確保 .env 存在 (建議正式機手動維護 .env不隨 git 連動)
# if [ ! -f .env ]; then cp .env.example .env; fi
# # 2. 啟動容器
# docker compose up -d --build
# # 3. 執行 Laravel 正式環境優化流程
# docker exec -u 1000:1000 koori-erp-laravel-prod sh -c "
# composer install --no-dev --optimize-autoloader &&
# npm install &&
# npm run build &&
# php artisan migrate --force &&
# php artisan config:cache &&
# php artisan route:cache &&
# php artisan view:cache
# "