Skip to content

Merge branch 'dev'

Merge branch 'dev' #18

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) If deploy failed, Redeploy using URL
if [ $EXIT_CODE -ne 0 ]; then
echo "❗️ Initial deployment failed (exit code=$EXIT_CODE). 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
fi