55 branches-ignore :
66 - main
77 paths :
8- - ' apps/web-roo-code/**'
8+ - " apps/web-roo-code/**"
9+ pull_request :
10+ paths :
11+ - " apps/web-roo-code/**"
912 workflow_dispatch :
1013
1114env :
@@ -21,11 +24,11 @@ jobs:
2124 - name : Check if VERCEL_TOKEN exists
2225 id : check
2326 run : |
24- if [ -n "${{ secrets.VERCEL_TOKEN }}" ]; then
25- echo "has-vercel-token=true" >> $GITHUB_OUTPUT
26- else
27- echo "has-vercel-token=false" >> $GITHUB_OUTPUT
28- fi
27+ if [ -n "${{ secrets.VERCEL_TOKEN }}" ]; then
28+ echo "has-vercel-token=true" >> $GITHUB_OUTPUT
29+ else
30+ echo "has-vercel-token=false" >> $GITHUB_OUTPUT
31+ fi
2932
3033 preview :
3134 runs-on : ubuntu-latest
4346 - name : Build Project Artifacts
4447 run : npx vercel build --token=${{ secrets.VERCEL_TOKEN }}
4548 - name : Deploy Project Artifacts to Vercel
46- run : npx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
49+ id : deploy
50+ run : |
51+ DEPLOYMENT_URL=$(npx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
52+ echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT
53+ echo "Preview deployed to: $DEPLOYMENT_URL"
54+
55+ - name : Comment PR with preview link
56+ if : github.event_name == 'pull_request'
57+ uses : actions/github-script@v7
58+ with :
59+ script : |
60+ const deploymentUrl = '${{ steps.deploy.outputs.deployment_url }}';
61+ const commentIdentifier = '<!-- roo-preview-comment -->';
62+
63+ const { data: comments } = await github.rest.issues.listComments({
64+ owner: context.repo.owner,
65+ repo: context.repo.repo,
66+ issue_number: context.issue.number,
67+ });
68+
69+ const existingComment = comments.find(comment =>
70+ comment.body.includes(commentIdentifier)
71+ );
72+
73+ if (existingComment) {
74+ return;
75+ }
76+
77+ const comment = commentIdentifier + '\n🚀 **Preview deployed!**\n\nYour changes have been deployed to Vercel:\n\n**Preview URL:** ' + deploymentUrl + '\n\nThis preview will be updated automatically when you push new commits to this PR.';
78+
79+ await github.rest.issues.createComment({
80+ owner: context.repo.owner,
81+ repo: context.repo.repo,
82+ issue_number: context.issue.number,
83+ body: comment
84+ });
0 commit comments