From 5fcc04b5f9d6ece19e329e26620f0033ede98532 Mon Sep 17 00:00:00 2001 From: henry yo Date: Tue, 30 Jun 2026 17:36:15 +0800 Subject: [PATCH] fix: change deploy.yaml --- .gitea/workflows/deploy.yaml | 42 ++++++++++++++++++++++++++++++++++++ .gitea/workflows/deploy.yml | 28 ------------------------ 2 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 .gitea/workflows/deploy.yaml delete mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..29bb7e3 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,42 @@ +name: Deploy Frontend to 1Panel + +on: + push: + branches: + - main + +jobs: + build-and-deploy: + runs-on: ubuntu-22.04 + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 22 + + - name: Install Dependencies + run: npm install + + # 🎯 關鍵新增:在 Build 之前,強行產生 .env.production + - name: Inject Environment Variables + run: | + echo "VITE_BACKEND_URL=https://fin-buddy.duckdns.org/api/v1" > .env.production + + - name: Build Project + run: npm run build # 🎯 Vite 會在這裡讀取剛剛產生的 .env.production,把網址寫死進去! + - name: Install Dependencies + run: npm install + + # 🎯 關鍵步驟:在 Build 之前,把 Secret 倒出來變成 .env.production + - name: Generate Environment Variables + run: | + cat << 'EOF' > .env.production + ${{ secrets.ENV_FILE }} + EOF + + - name: Stream Dist out of Container + run: | + tar -czf - -C dist . | nc -w 3 localhost 9999 || true diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml deleted file mode 100644 index f03efde..0000000 --- a/.gitea/workflows/deploy.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Deploy Frontend to 1Panel - -on: - push: - branches: - - main # 🎯 或者是 master,看你的預設分支是哪一個 - -jobs: - build-and-deploy: - runs-on: ubuntu-22.04 - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 22 # 🎯 對齊你的 Node 版本 - - - name: Install Dependencies - run: npm install - - - name: Build Project - run: npm run build # 🎯 編譯出 dist 資料夾 - - - name: Stream Dist out of Container - run: | - tar -czf - -C dist . | nc -w 3 localhost 9999 || true \ No newline at end of file