diff --git a/.github/workflows/frontend-deploy.yml b/.github/workflows/frontend-deploy.yml index 2344661..a2fb95d 100644 --- a/.github/workflows/frontend-deploy.yml +++ b/.github/workflows/frontend-deploy.yml @@ -21,20 +21,26 @@ jobs: with: node-version: 20 # 使用 Node.js 版本 20。 - # 3. 安裝依賴項 + # 3. 設置環境變數並生成 .env.production + - name: Set environment variables + run: | + echo "REACT_APP_BASENAME=${{ secrets.REACT_APP_BASENAME }}" >> .env.production + echo "REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}" >> .env.production + + # 4. 安裝依賴項 - name: Install dependencies run: npm install - # 4. 動態添加 homepage 欄位至 package.json + # 5. 動態添加 homepage 欄位至 package.json - name: Add homepage field dynamically run: | node -e "let pkg=require('./package.json'); pkg.homepage='https://ysq-qi.github.io/sideproject2405/'; require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));" - # 5. 建置專案 + # 6. 建置專案 - name: Build project run: npm run build - # 6. 部署至 GitHub Pages + # 7. 部署至 GitHub Pages - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: diff --git a/.gitignore b/.gitignore index cf5dc60..8566788 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ .env.test.local .env.production.local .env +.env.production .env.backend npm-debug.log*