Add Phase 5 Svelte dashboard on Cloudflare Pages #1
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
| name: Deploy dashboard | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'dashboard/**' | |
| - '.github/workflows/deploy-dashboard.yml' | |
| pull_request: | |
| paths: | |
| - 'dashboard/**' | |
| - '.github/workflows/deploy-dashboard.yml' | |
| permissions: | |
| contents: read | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: ${{ github.ref == 'refs/heads/main' && 'production' || 'preview' }} | |
| url: ${{ steps.deploy.outputs.deployment-url }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| cache-dependency-path: dashboard/package-lock.json | |
| - name: Install dependencies | |
| working-directory: dashboard | |
| run: npm ci | |
| - name: Build | |
| working-directory: dashboard | |
| run: npm run build | |
| - name: Deploy to Cloudflare Pages | |
| id: deploy | |
| working-directory: dashboard | |
| run: | | |
| OUTPUT=$(node_modules/.bin/wrangler pages deploy \ | |
| ${{ github.ref != 'refs/heads/main' && format('--branch {0}', github.head_ref || github.ref_name) || '' }}) | |
| echo "$OUTPUT" | |
| URL=$(echo "$OUTPUT" | grep -oP 'https://[^\s]+\.pages\.dev[^\s]*' | tail -1) | |
| echo "deployment-url=${URL}" >> "$GITHUB_OUTPUT" | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |