deploement config 2 #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ───────────────────────────────────────────── | |
| # GitHub Actions — Deploy Frontend to Azure Static Web Apps | |
| # | |
| # Setup (one-time): | |
| # 1. Create your Azure Static Web App in the portal | |
| # 2. Go to your Static Web App → Manage deployment token | |
| # 3. Add it as a GitHub repo secret: | |
| # Settings → Secrets → Actions → New secret | |
| # Name: AZURE_STATIC_WEB_APPS_API_TOKEN | |
| # 4. Add your VM's public IP or domain as another secret: | |
| # Name: VITE_API_BASE_URL value: http://YOUR_VM_IP | |
| # | |
| # Triggers: every push to main | |
| # ───────────────────────────────────────────── | |
| name: Deploy Frontend to Azure Static Web Apps | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "frontend/**" | |
| - ".github/workflows/deploy-frontend.yml" | |
| workflow_dispatch: # allow manual trigger from GitHub UI | |
| jobs: | |
| build_and_deploy: | |
| runs-on: ubuntu-latest | |
| name: Build and Deploy | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Build React app | |
| working-directory: frontend | |
| env: | |
| # Injected from GitHub secret — your VM's public IP or domain | |
| VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }} | |
| run: npm run build | |
| - name: Deploy to Azure Static Web Apps | |
| uses: Azure/static-web-apps-deploy@v1 | |
| with: | |
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| action: "upload" | |
| app_location: "frontend" | |
| output_location: "dist" | |
| skip_app_build: true # we built above with env vars injected |