|
| 1 | +name: Deploy Vite with GitHub Pages dependencies preinstalled |
| 2 | + |
| 3 | +on: |
| 4 | + # Runs on pushes targeting the default branch |
| 5 | + push: |
| 6 | + branches: ["main"] |
| 7 | + |
| 8 | + # Allows you to run this workflow manually from the Actions tab |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 18 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 19 | +concurrency: |
| 20 | + group: "pages" |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +jobs: |
| 24 | + # Build job |
| 25 | + build: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v4 |
| 30 | + - name: Setup Pages |
| 31 | + uses: actions/configure-pages@v5 |
| 32 | + |
| 33 | + # Set up .env file with GitHub secrets |
| 34 | + - name: Set up .env with secrets |
| 35 | + run: | |
| 36 | + echo "VITE_SUPABASE_URL=${{ secrets.VITE_SUPABASE_URL }}" > .env |
| 37 | + echo "VITE_SUPABASE_ANON_KEY=${{ secrets.VITE_SUPABASE_ANON_KEY }}" >> .env |
| 38 | + echo "VITE_NCU_PORTAL_CLIENT_ID=${{ secrets.VITE_NCU_PORTAL_CLIENT_ID }}" >> .env |
| 39 | + echo "VITE_NCU_PORTAL_SECRET=${{ secrets.VITE_NCU_PORTAL_SECRET }}" >> .env |
| 40 | + env: |
| 41 | + VITE_SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }} |
| 42 | + VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }} |
| 43 | + VITE_NCU_PORTAL_CLIENT_ID: ${{ secrets.VITE_NCU_PORTAL_CLIENT_ID }} |
| 44 | + VITE_NCU_PORTAL_SECRET: ${{ secrets.VITE_NCU_PORTAL_SECRET }} |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + # Debug - Verify .env file creation |
| 49 | + - name: Debug - Verify .env file creation |
| 50 | + run: | |
| 51 | + if [ -f .env ]; then |
| 52 | + echo ".env file exists!" |
| 53 | + cat .env |
| 54 | + else |
| 55 | + echo ".env file does not exist!" |
| 56 | + fi |
| 57 | + |
| 58 | + |
| 59 | + - name: Build with Vite |
| 60 | + run: npm ci && npm run build |
| 61 | + - name: Upload artifact |
| 62 | + uses: actions/upload-pages-artifact@v3 |
| 63 | + with: |
| 64 | + path: dist/ |
| 65 | + # Deployment job |
| 66 | + deploy: |
| 67 | + environment: |
| 68 | + name: github-pages |
| 69 | + url: ${{ steps.deployment.outputs.page_url }} |
| 70 | + runs-on: ubuntu-latest |
| 71 | + needs: build |
| 72 | + steps: |
| 73 | + - name: Deploy to GitHub Pages |
| 74 | + id: deployment |
| 75 | + uses: actions/deploy-pages@v4 |
0 commit comments