@@ -96,24 +96,48 @@ jobs:
9696 vercel-args : " --prebuilt"
9797
9898 wait-and-comment :
99- needs : deploy-to-vercel
99+ needs : preview-sync
100100 runs-on : ubuntu-latest
101101
102102 steps :
103- - name : Post "Building..." Comment Immediately
103+ - name : Install Vercel CLI
104+ run : npm install -g vercel
105+
106+ - name : Post "Building..." Sticky Comment
104107 uses : marocchino/sticky-pull-request-comment@v2
105108 with :
106109 number : ${{ github.event.pull_request.number }}
107110 header : VercelPreview
108111 message : |
109112 🟡 **Vercel preview is building...**
110113
114+ - name : Clone marketing-site preview branch
115+ env :
116+ TOKEN : ${{ secrets.SERVICE_BOT_TOKEN }}
117+ run : |
118+ git clone https://x-access-token:${TOKEN}@github.com/${{ secrets.SYNC_REPO }}.git private-repo
119+ cd private-repo
120+ git checkout $BRANCH_NAME
121+
122+ - name : Deploy to Vercel via CLI
123+ id : deploy
124+ working-directory : private-repo
125+ env :
126+ VERCEL_TOKEN : ${{ secrets.SERVICE_BOT_VERCEL }}
127+ run : |
128+ DEPLOY_OUTPUT=$(vercel --prebuilt --yes --token $VERCEL_TOKEN --scope ${{ secrets.VERCEL_TEAM_ID }} --confirm)
129+ echo "$DEPLOY_OUTPUT"
130+ DEPLOYMENT_URL=$(echo "$DEPLOY_OUTPUT" | grep -o 'https://[^ ]*\.vercel\.app' | tail -n1)
131+ DEPLOYMENT_ID=$(echo "$DEPLOY_OUTPUT" | grep -o 'deploymentId":"[^"]*' | cut -d'"' -f3)
132+ echo "deployment-url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT
133+ echo "deployment-id=$DEPLOYMENT_ID" >> $GITHUB_OUTPUT
134+
111135 - name : Wait for Vercel Deployment
112136 id : wait
113137 uses : vercel/wait-for-deployment@v1
114138 with :
115139 token : ${{ secrets.SERVICE_BOT_VERCEL }}
116- deployment-id : ${{ needs .deploy-to-vercel .outputs.deployment-id }}
140+ deployment-id : ${{ steps .deploy.outputs.deployment-id }}
117141 timeout : 900
118142
119143 - name : Update Sticky Comment with Success
@@ -124,7 +148,7 @@ jobs:
124148 header : VercelPreview
125149 message : |
126150 ✅ **Vercel preview is ready!**
127- 🔗 [View deployment](${{ steps.wait .outputs.deployment-url }})
151+ 🔗 [View deployment](${{ steps.deploy .outputs.deployment-url }})
128152
129153 - name : Update Sticky Comment with Failure
130154 if : ${{ steps.wait.outputs.ready-state != 'READY' }}
0 commit comments