-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (83 loc) · 2.73 KB
/
Copy pathpreview-deploy.yml
File metadata and controls
96 lines (83 loc) · 2.73 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
89
90
91
92
93
94
95
96
name: Preview Deploy
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
concurrency:
group: preview-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build Preview
runs-on: ubuntu-latest
outputs:
frontend-preview-url: ${{ steps.vercel.outputs.preview-url }}
steps:
- 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 preview
working-directory: frontend
env:
VITE_NETWORK: mainnet
VITE_APP_URL: ${{ secrets.VERCEL_PREVIEW_URL || format('https://{0}-tipstream-silk.vercel.app', github.head_ref) }}
run: npm run build
- name: Upload preview artifact
uses: actions/upload-artifact@v4
with:
name: preview-dist
path: frontend/dist
retention-days: 7
deploy-preview:
name: Deploy to Preview
runs-on: ubuntu-latest
needs: build
if: github.event.action != 'closed'
steps:
- uses: actions/checkout@v4
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: preview-dist
path: frontend/dist
- name: Deploy to Vercel Preview
id: vercel
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
working-directory: frontend
scope: ${{ secrets.VERCEL_ORG_ID }}
- name: Smoke test preview
run: |
PREVIEW_URL="${{ steps.vercel.outputs.preview-url }}"
echo "Testing preview URL: $PREVIEW_URL"
curl -f -s "$PREVIEW_URL" | grep -q "TipStream" && echo "Preview healthy" || exit 1
- name: Comment PR with preview URL
if: success()
uses: actions/github-script@v7
with:
script: |
const url = "${{ steps.vercel.outputs.preview-url }}";
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Preview deployed: [${url}](${url})`
});
cleanup-preview:
name: Cleanup Preview
runs-on: ubuntu-latest
if: github.event.action == 'closed'
steps:
- name: Cleanup closed preview
run: echo "PR closed - cleanup handled by Vercel"