6868
6969 - name : Upsert PR comment with Devin Review link
7070 id : comment
71- continue-on-error : true
7271 uses : actions/github-script@v8
7372 env :
7473 PR_NUMBER : ${{ steps.review.outputs.number }}
7877 script : |
7978 const marker = '<!-- devin-review-link -->';
8079 const issue_number = Number(process.env.PR_NUMBER);
80+ core.setOutput('posted', 'false');
8181 const body = [
8282 marker,
8383 'Devin Review is available for this pull request.',
@@ -88,35 +88,45 @@ jobs:
8888 'This link opens the hosted Devin Review page for the current PR.',
8989 ].join('\n');
9090
91- const comments = await github.paginate(github.rest.issues.listComments, {
92- owner: context.repo.owner,
93- repo: context.repo.repo,
94- issue_number,
95- per_page: 100,
96- });
97-
98- const existing = comments.find((comment) => comment.body && comment.body.includes(marker));
99-
100- if (existing) {
101- await github.rest.issues.updateComment({
102- owner: context.repo.owner,
103- repo: context.repo.repo,
104- comment_id: existing.id,
105- body,
106- });
107- core.info(`Updated existing Devin Review comment: ${existing.html_url}`);
108- } else {
109- const created = await github.rest.issues.createComment({
91+ try {
92+ const comments = await github.paginate(github.rest.issues.listComments, {
11093 owner: context.repo.owner,
11194 repo: context.repo.repo,
11295 issue_number,
113- body ,
96+ per_page: 100 ,
11497 });
115- core.info(`Created Devin Review comment: ${created.data.html_url}`);
98+
99+ const existing = comments.find((comment) => comment.body && comment.body.includes(marker));
100+
101+ if (existing) {
102+ await github.rest.issues.updateComment({
103+ owner: context.repo.owner,
104+ repo: context.repo.repo,
105+ comment_id: existing.id,
106+ body,
107+ });
108+ core.info(`Updated existing Devin Review comment: ${existing.html_url}`);
109+ } else {
110+ const created = await github.rest.issues.createComment({
111+ owner: context.repo.owner,
112+ repo: context.repo.repo,
113+ issue_number,
114+ body,
115+ });
116+ core.info(`Created Devin Review comment: ${created.data.html_url}`);
117+ }
118+
119+ core.setOutput('posted', 'true');
120+ } catch (error) {
121+ if (error && error.status === 403) {
122+ core.warning('PR comment was not posted because this repository grants GitHub Actions a read-only GITHUB_TOKEN.');
123+ } else {
124+ throw error;
125+ }
116126 }
117127
118128 - name : Report comment permission limitation
119- if : ${{ steps.comment.outcome == 'failure ' }}
129+ if : ${{ steps.comment.outputs.posted != 'true ' }}
120130 run : |
121131 {
122132 echo
0 commit comments