-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 2.03 KB
/
Copy pathdeploy-vercel.yml
File metadata and controls
64 lines (55 loc) · 2.03 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
name: Deploy to Vercel with Redeploy-on-Failure
on:
pull_request:
types: [closed]
jobs:
deploy:
if: ${{ contains(github.event.pull_request.title, '[WEB]') }}
runs-on: ubuntu-latest
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
- name: Link Vercel Project
run: |
npx vercel link --cwd . --yes \
--token "$VERCEL_TOKEN" \
--scope "$VERCEL_ORG_ID" \
--project "$VERCEL_PROJECT_ID"
- name: Deploy & Redeploy on Failure
shell: bash
run: |
set +e
# 1) Initial production deploy (capture logs)
npx vercel --prod --yes \
--token "$VERCEL_TOKEN" \
--scope "$VERCEL_ORG_ID" > deploy.log 2>&1
EXIT_CODE=$?
cat deploy.log
# Extract deployment URL
DEPLOY_URL=$(grep -Eo 'https?://[A-Za-z0-9.-]+\.vercel\.app' deploy.log | head -n1)
# 2) Check if failure is due to @repo/types module error and redeploy if so
if [ $EXIT_CODE -ne 0 ]; then
if grep -q "Cannot find module '@repo/types'" deploy.log; then
echo "❗️ Initial deployment failed due to @repo/types module error. Redeploying..."
npx vercel redeploy "$DEPLOY_URL" \
--token "$VERCEL_TOKEN" \
--scope "$VERCEL_ORG_ID"
REDO_EXIT=$?
if [ $REDO_EXIT -ne 0 ]; then
echo "::error::Redeploy failed (exit code=$REDO_EXIT)!"
exit 1
fi
else
echo "❌ Deployment failed but not due to @repo/types module error. Exiting..."
echo "::error::Deployment failed with exit code $EXIT_CODE"
exit 1
fi
fi