# GitHub Actions Workflow for Frontend Deployment to GitHub Pages # Automatically deploys the React frontend when changes are pushed to main name: Deploy Frontend to GitHub Pages on: push: branches: [main] paths: - 'frontend/**' - '.github/workflows/deploy-frontend.yml' workflow_dispatch: # Allow manual deployment # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write # Allow only one concurrent deployment concurrency: group: 'pages' cancel-in-progress: true jobs: build: name: Build Frontend runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup 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 project working-directory: frontend run: npm run build env: VITE_API_BASE_URL: ${{ vars.VITE_API_BASE_URL || 'http://localhost:8000' }} - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: frontend/dist deploy: name: Deploy to GitHub Pages needs: build runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4