55 branches-ignore :
66 - main
77 paths :
8- - ' apps/web-roo-code/**'
8+ - " apps/web-roo-code/**"
99 pull_request :
1010 paths :
11- - ' apps/web-roo-code/**'
11+ - " apps/web-roo-code/**"
1212 workflow_dispatch :
1313
1414env :
@@ -24,11 +24,11 @@ jobs:
2424 - name : Check if VERCEL_TOKEN exists
2525 id : check
2626 run : |
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
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
3232
3333 preview :
3434 runs-on : ubuntu-latest
4646 - name : Build Project Artifacts
4747 run : npx vercel build --token=${{ secrets.VERCEL_TOKEN }}
4848 - name : Deploy Project Artifacts to Vercel
49- 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