-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (104 loc) · 3.6 KB
/
deploy-dev.yml
File metadata and controls
123 lines (104 loc) · 3.6 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Deploy Dev
on:
push:
branches: [dev]
workflow_dispatch:
inputs:
dry_run:
description: Dry run - validate without deploying
required: false
default: false
type: boolean
concurrency:
group: deploy-dev
cancel-in-progress: false
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
jobs:
validate:
name: Validate
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '22'
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- name: Typecheck
run: pnpm typecheck
- name: Build
run: pnpm build
- name: Check links
run: pnpm check-links
deploy-preview:
name: Deploy Preview
needs: validate
runs-on: ubuntu-latest
timeout-minutes: 15
if: inputs.dry_run != true
outputs:
preview_url: ${{ steps.deploy.outputs.preview_url }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '22'
cache: 'pnpm'
- run: npm install --global vercel@53
- run: vercel pull --yes --environment=preview --token=$VERCEL_TOKEN
- run: vercel build --token=$VERCEL_TOKEN
- name: Deploy to Vercel Preview
id: deploy
run: |
DEPLOYMENT_URL=$(vercel deploy --prebuilt --token=$VERCEL_TOKEN)
echo "preview_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT
echo "Deployed to: $DEPLOYMENT_URL"
echo "## Preview Deployment" >> $GITHUB_STEP_SUMMARY
echo "**URL**: $DEPLOYMENT_URL" >> $GITHUB_STEP_SUMMARY
health-check:
name: Health Check
needs: deploy-preview
runs-on: ubuntu-latest
timeout-minutes: 5
if: inputs.dry_run != true
steps:
- name: Wait and check health
run: |
sleep 30
PREVIEW_URL="${{ needs.deploy-preview.outputs.preview_url }}"
for i in 1 2 3 4 5; do
HTTP_STATUS=$(curl -sL -o /dev/null -w "%{http_code}" "$PREVIEW_URL" --max-time 30)
if [ "$HTTP_STATUS" = "200" ]; then
echo "Health check passed (HTTP $HTTP_STATUS)"
echo "## Health Check" >> $GITHUB_STEP_SUMMARY
echo "**Status**: Passed" >> $GITHUB_STEP_SUMMARY
exit 0
fi
echo "Attempt $i: HTTP $HTTP_STATUS, retrying..."
sleep 10
done
echo "Health check FAILED"
exit 1
dry-run-summary:
name: Dry Run Summary
needs: validate
runs-on: ubuntu-latest
if: inputs.dry_run == true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 10
- run: |
echo "=== DRY RUN MODE ==="
echo "Would deploy dev branch to Vercel Preview"
echo "## Dry Run Summary" >> $GITHUB_STEP_SUMMARY
echo "Validation passed. Would deploy to Vercel Preview." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Recent commits:" >> $GITHUB_STEP_SUMMARY
git log --oneline -10 >> $GITHUB_STEP_SUMMARY