···
const { execFileSync } = require('node:child_process')
const { classify } = require('../supportedBranches.js')
const withRateLimit = require('./withRateLimit.js')
5
+
const { dismissReviews, postReview } = require('./reviews.js')
await withRateLimit({ github, core }, async (stats) => {
···
// An empty results array will always trigger this condition, which is helpful
// to clean up reviews created by the prepare step when on the wrong branch.
if (results.every(({ severity }) => severity === 'info')) {
198
-
await github.paginate(github.rest.pulls.listReviews, {
203
-
.filter((review) => review.user.login === 'github-actions[bot]')
204
-
.map(async (review) => {
205
-
if (review.state === 'CHANGES_REQUESTED') {
206
-
await github.rest.pulls.dismissReview({
209
-
review_id: review.id,
210
-
message: 'All good now, thank you!',
213
-
await github.graphql(
214
-
`mutation($node_id:ID!) {
215
-
minimizeComment(input: {
216
-
classifier: RESOLVED,
217
-
subjectId: $node_id
219
-
{ clientMutationId }
221
-
{ node_id: review.node_id },
196
+
await dismissReviews({ github, context, dry })
···
const body = core.summary.stringify()
345
-
const pendingReview = (
346
-
await github.paginate(github.rest.pulls.listReviews, {
352
-
review.user.login === 'github-actions[bot]' &&
353
-
// If a review is still pending, we can just update this instead
354
-
// of posting a new one.
355
-
(review.state === 'CHANGES_REQUESTED' ||
356
-
// No need to post a new review, if an older one with the exact
357
-
// same content had already been dismissed.
358
-
review.body === body),
363
-
core.info(`pending review found: ${pendingReview.html_url}`)
364
-
else core.info('no pending review found')
366
-
// Either of those two requests could fail for very long comments. This can only happen
367
-
// with multiple commits all hitting the truncation limit for the diff. If you ever hit
368
-
// this case, consider just splitting up those commits into multiple PRs.
369
-
if (pendingReview) {
370
-
await github.rest.pulls.updateReview({
373
-
review_id: pendingReview.id,
377
-
await github.rest.pulls.createReview({
380
-
event: 'REQUEST_CHANGES',
316
+
// Posting a review could fail for very long comments. This can only happen with
317
+
// multiple commits all hitting the truncation limit for the diff. If you ever hit
318
+
// this case, consider just splitting up those commits into multiple PRs.
319
+
await postReview({ github, context, core, dry, body })