-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (84 loc) · 3.08 KB
/
deploy.yml
File metadata and controls
88 lines (84 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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 }}