Skip to content

Merge branch 'dev'

Merge branch 'dev' #38

Workflow file for this run

name: Deploy to Vercel with Redeploy-on-Failure
on:
push:
branches:
- main
jobs:
deploy:
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