Files
star-erp/.gitea/workflows/deploy.yaml
sky121113 b8995ece05
Some checks failed
Koori-ERP-Demo-Deploy / sync-update (push) Failing after 42s
test2
2026-01-05 21:46:01 +08:00

96 lines
3.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-Demo-Deploy
# on:
# push:
# branches:
# - main
# 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
- 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