Files
star-erp/.gitea/workflows/deploy.yaml
sky121113 ca40bae502
All checks were successful
Koori-ERP-Deploy / auto-deploy (push) Successful in 38s
v7
2025-12-31 10:37:13 +08:00

69 lines
2.9 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-Deploy
on:
push:
branches:
- main
jobs:
auto-deploy:
runs-on: ubuntu-latest
steps:
- name: 1. Checkout Code
uses: actions/checkout@v3
with:
# --- 關鍵:直接指定 Gitea 的伺服器網址為 IP ---
github-server-url: http://192.168.0.103:3000
repository: ${{ gitea.repository }}
# ------------------------------------------
- name: 2. Create .env from Secrets
run: echo "${{ secrets.DOT_ENV }}" > .env
- name: 3. Build and Start Docker
run: |
# 1. 強制讀取當前目錄剛生成的 .env 內容(確保拿到 8081
# 並直接導出給 Shell
export $(grep -v '^#' .env | xargs)
# 2. 顯示一下現在讀到的埠號,確認沒讀錯 (會在 Action 日誌看到)
echo "Debug: Current APP_PORT is $APP_PORT"
# 3. 在啟動指令前,直接把變數塞進去 (這招優先權最高,會覆蓋所有 .env)
APP_PORT=$APP_PORT docker compose down --remove-orphans
APP_PORT=$APP_PORT docker compose up -d --build --force-recreate
# 【強制注入】不管是掛載失效還是路徑對不上,這招一定能把 web.php 送進去
tar -cf - . | docker exec -i koori-erp-laravel.test-1 tar -xf - -C /var/www/html
# 修正權限這步沒做Laravel 後面也會噴錯)
docker exec koori-erp-laravel.test-1 chown -R www-data:www-data /var/www/html
- name: 4. Initialize Laravel
run: |
# 先進容器確認 composer.json 是否真的在那裡
docker exec koori-erp-laravel.test-1 ls -F /var/www/html/
# 執行安裝
docker exec -w /var/www/html koori-erp-laravel.test-1 composer install --optimize-autoloader --no-dev
# 其他初始化指令
docker exec koori-erp-laravel.test-1 php artisan key:generate --force
docker exec koori-erp-laravel.test-1 php artisan storage:link
docker exec koori-erp-laravel.test-1 php artisan migrate --force
- name: 5. Fix Permissions (Sail Mode)
run: |
# 同時照顧 www-data 和 sail
docker exec koori-erp-laravel.test-1 chmod -R 777 /var/www/html/storage
docker exec koori-erp-laravel.test-1 php artisan view:clear
- name: 6. Build Frontend Assets (Vite)
run: |
# 1. 進入容器安裝 NPM 套件
docker exec -w /var/www/html koori-erp-laravel.test-1 npm install
# 2. 執行 Vite 編譯 (這會產生 manifest.json)
docker exec -w /var/www/html koori-erp-laravel.test-1 npm run build
# 3. 再次確保編譯出來的 public/build 權限也是正確的
docker exec koori-erp-laravel.test-1 chown -R www-data:www-data /var/www/html/public