|
8 | 8 | - 'plugins/**' |
9 | 9 |
|
10 | 10 | permissions: |
| 11 | + contents: read |
| 12 | + issues: write |
11 | 13 | pull-requests: write |
12 | 14 |
|
13 | 15 | jobs: |
@@ -72,28 +74,37 @@ jobs: |
72 | 74 | body = marker + '\n## Plugin TOML Validation Report\n\n> No validation report generated.'; |
73 | 75 | } |
74 | 76 |
|
75 | | - const { data: comments } = await github.rest.issues.listComments({ |
76 | | - owner: context.repo.owner, |
77 | | - repo: context.repo.repo, |
78 | | - issue_number: context.issue.number, |
79 | | - }); |
80 | | -
|
81 | | - const existing = comments.find(c => c.body && c.body.includes(marker)); |
82 | | -
|
83 | | - if (existing) { |
84 | | - await github.rest.issues.updateComment({ |
85 | | - owner: context.repo.owner, |
86 | | - repo: context.repo.repo, |
87 | | - comment_id: existing.id, |
88 | | - body, |
89 | | - }); |
90 | | - } else { |
91 | | - await github.rest.issues.createComment({ |
| 77 | + try { |
| 78 | + const { data: comments } = await github.rest.issues.listComments({ |
92 | 79 | owner: context.repo.owner, |
93 | 80 | repo: context.repo.repo, |
94 | 81 | issue_number: context.issue.number, |
95 | | - body, |
96 | 82 | }); |
| 83 | +
|
| 84 | + const existing = comments.find(c => c.body && c.body.includes(marker)); |
| 85 | +
|
| 86 | + if (existing) { |
| 87 | + await github.rest.issues.updateComment({ |
| 88 | + owner: context.repo.owner, |
| 89 | + repo: context.repo.repo, |
| 90 | + comment_id: existing.id, |
| 91 | + body, |
| 92 | + }); |
| 93 | + } else { |
| 94 | + await github.rest.issues.createComment({ |
| 95 | + owner: context.repo.owner, |
| 96 | + repo: context.repo.repo, |
| 97 | + issue_number: context.issue.number, |
| 98 | + body, |
| 99 | + }); |
| 100 | + } |
| 101 | + } catch (error) { |
| 102 | + if (error.status === 403) { |
| 103 | + core.warning(`Skipping PR comment because the workflow token cannot write comments: ${error.message}`); |
| 104 | + return; |
| 105 | + } |
| 106 | +
|
| 107 | + throw error; |
97 | 108 | } |
98 | 109 |
|
99 | 110 | - name: Fail if validation failed |
|
0 commit comments