|
16 | 16 | timeout-minutes: 5 |
17 | 17 | permissions: |
18 | 18 | contents: read |
| 19 | + issues: write |
19 | 20 | pull-requests: read |
20 | 21 |
|
21 | 22 | steps: |
|
64 | 65 | echo "This workflow intentionally does not use DEVIN_API_KEY." |
65 | 66 | echo "For automatic Devin statuses or comments inside GitHub, connect the Devin GitHub integration and enable auto-review in Devin settings." |
66 | 67 | } >> "$GITHUB_STEP_SUMMARY" |
| 68 | +
|
| 69 | + - name: Upsert PR comment with Devin Review link |
| 70 | + uses: actions/github-script@v8 |
| 71 | + env: |
| 72 | + PR_NUMBER: ${{ steps.review.outputs.number }} |
| 73 | + PR_URL: ${{ steps.review.outputs.pr_url }} |
| 74 | + REVIEW_URL: ${{ steps.review.outputs.review_url }} |
| 75 | + with: |
| 76 | + script: | |
| 77 | + const marker = '<!-- devin-review-link -->'; |
| 78 | + const issue_number = Number(process.env.PR_NUMBER); |
| 79 | + const body = [ |
| 80 | + marker, |
| 81 | + 'Devin Review is available for this pull request.', |
| 82 | + '', |
| 83 | + `- GitHub PR: ${process.env.PR_URL}`, |
| 84 | + `- Devin Review: ${process.env.REVIEW_URL}`, |
| 85 | + '', |
| 86 | + 'This link opens the hosted Devin Review page for the current PR.', |
| 87 | + ].join('\n'); |
| 88 | +
|
| 89 | + const comments = await github.paginate(github.rest.issues.listComments, { |
| 90 | + owner: context.repo.owner, |
| 91 | + repo: context.repo.repo, |
| 92 | + issue_number, |
| 93 | + per_page: 100, |
| 94 | + }); |
| 95 | +
|
| 96 | + const existing = comments.find((comment) => comment.body && comment.body.includes(marker)); |
| 97 | +
|
| 98 | + if (existing) { |
| 99 | + await github.rest.issues.updateComment({ |
| 100 | + owner: context.repo.owner, |
| 101 | + repo: context.repo.repo, |
| 102 | + comment_id: existing.id, |
| 103 | + body, |
| 104 | + }); |
| 105 | + core.info(`Updated existing Devin Review comment: ${existing.html_url}`); |
| 106 | + } else { |
| 107 | + const created = await github.rest.issues.createComment({ |
| 108 | + owner: context.repo.owner, |
| 109 | + repo: context.repo.repo, |
| 110 | + issue_number, |
| 111 | + body, |
| 112 | + }); |
| 113 | + core.info(`Created Devin Review comment: ${created.data.html_url}`); |
| 114 | + } |
0 commit comments