@@ -59,11 +59,12 @@ jobs:
5959 vercel-token : ${{ secrets.VERCEL_TOKEN }}
6060 vercel-project-id : ${{ secrets.VERCEL_PROJECT_ID }}
6161 vercel-org-id : ${{ secrets.VERCEL_ORG_ID }}
62- github-comment : true
62+ github-comment : false
6363 env :
6464 VERCEL_TOKEN : ${{ secrets.VERCEL_TOKEN }}
6565
6666 - name : Comment preview URL on PR
67+ if : steps.vercel-preview.outcome == 'success'
6768 uses : actions/github-script@v8
6869 with :
6970 script : |
8081 body: `✅ Tests passed! Preview deployment ready:\n\n🔗 ${previewUrl}`
8182 });
8283
84+ - name : Comment preview failure on PR
85+ if : steps.vercel-preview.outcome != 'success'
86+ uses : actions/github-script@v8
87+ with :
88+ script : |
89+ const previewUrl = '${{ steps.vercel-preview.outputs.preview-url }}';
90+ const pr = context.payload.workflow_run.pull_requests && context.payload.workflow_run.pull_requests[0];
91+ if (!pr) {
92+ core.warning('No pull request metadata available; skipping preview failure comment.');
93+ return;
94+ }
95+ const linkLine = previewUrl ? `\n\n🔗 ${previewUrl}` : '\n\n🔗 View the failed deployment in Vercel.';
96+ await github.rest.issues.createComment({
97+ issue_number: pr.number,
98+ owner: context.repo.owner,
99+ repo: context.repo.repo,
100+ body: `❌ Preview deployment failed.${linkLine}\n\nPlease review the Vercel build logs for details.`
101+ });
102+
83103 deploy-production :
84104 name : Deploy to Production (Vercel)
85105 runs-on : ubuntu-latest
@@ -111,3 +131,19 @@ jobs:
111131 run : |
112132 echo "🚀 Production deployment completed"
113133 echo "Production URL: ${{ steps.vercel-production.outputs.preview-url }}"
134+
135+ - name : Comment production deployment failure on commit
136+ if : steps.vercel-production.outcome != 'success'
137+ uses : actions/github-script@v8
138+ with :
139+ script : |
140+ const targetUrl = '${{ steps.vercel-production.outputs.preview-url }}';
141+ const body = targetUrl
142+ ? `❌ Production deployment failed.\n\n🔗 ${targetUrl}\n\nPlease review the Vercel logs.`
143+ : '❌ Production deployment failed. Please review the Vercel logs.'
144+ await github.rest.repos.createCommitComment({
145+ owner: context.repo.owner,
146+ repo: context.repo.repo,
147+ commit_sha: context.payload.workflow_run.head_sha,
148+ body,
149+ });
0 commit comments