Feat/0323 #2
Workflow file for this run
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 to Cloudflare Pages | |
| on: | |
| pull_request: | |
| branches: [develop] | |
| push: | |
| branches: [develop] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| deploy-preview: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| environment: Preview | |
| env: | |
| CONVEX_PREVIEW_NAME: pr-${{ github.event.pull_request.number }}-deploy | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Deploy Convex Preview | |
| id: convex | |
| run: | | |
| npx convex deploy --preview-create "$CONVEX_PREVIEW_NAME" \ | |
| --cmd 'echo "PREVIEW_URL=$CONVEX_URL" >> "$GITHUB_OUTPUT"' \ | |
| --cmd-url-env-var-name CONVEX_URL | |
| env: | |
| CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }} | |
| - name: Seed Database | |
| run: | | |
| npx convex import --replace-all convex-seeds/seeds/db.zip --yes \ | |
| --preview-name "${{ env.CONVEX_PREVIEW_NAME }}" | |
| env: | |
| CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }} | |
| - name: Build | |
| run: pnpm build | |
| env: | |
| VITE_CONVEX_URL: ${{ steps.convex.outputs.PREVIEW_URL }} | |
| VITE_CLERK_PUBLISHABLE_KEY: ${{ secrets.VITE_CLERK_PUBLISHABLE_KEY }} | |
| - name: Deploy to Cloudflare Pages | |
| id: deploy | |
| run: | | |
| DEPLOY_OUTPUT=$(npx wrangler pages deploy dist \ | |
| --project-name yps-crispy-carnival \ | |
| --branch "pr-${{ github.event.pull_request.number }}" 2>&1) | |
| echo "$DEPLOY_OUTPUT" | |
| DEPLOY_URL=$(echo "$DEPLOY_OUTPUT" | grep -oP 'https://[^\s]+\.pages\.dev' | tail -1) | |
| echo "DEPLOY_URL=$DEPLOY_URL" >> "$GITHUB_OUTPUT" | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| - name: Comment PR with Deploy URL | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const deployUrl = '${{ steps.deploy.outputs.DEPLOY_URL }}'; | |
| const convexUrl = '${{ steps.convex.outputs.PREVIEW_URL }}'; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `## 🚀 Preview Deploy\n\n**App:** ${deployUrl}\n**Convex:** ${convexUrl}` | |
| }); | |
| deploy-production: | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| environment: Production | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Build | |
| run: pnpm build | |
| env: | |
| VITE_CONVEX_URL: ${{ secrets.VITE_CONVEX_URL }} | |
| VITE_CLERK_PUBLISHABLE_KEY: ${{ secrets.VITE_CLERK_PUBLISHABLE_KEY }} | |
| - name: Deploy to Cloudflare Pages | |
| run: | | |
| npx wrangler pages deploy dist \ | |
| --project-name yps-crispy-carnival \ | |
| --branch main | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |