ci/github-script/{reviews,check-target-branch,commits,prepare}: add sticky review support

This commit is contained in:
Michael Daniels 2026-01-24 09:47:58 -05:00
commit 4447561c05
No known key found for this signature in database
4 changed files with 177 additions and 43 deletions

View file

@ -6,8 +6,9 @@
const { classify, split } = require('../supportedBranches.js')
const { readFile } = require('node:fs/promises')
const { postReview } = require('./reviews.js')
const { postReview, dismissReviews } = require('./reviews.js')
const reviewKey = 'check-target-branch'
/**
* @param {{
* github: InstanceType<import('@actions/github/lib/utils').GitHub>,
@ -43,6 +44,15 @@ async function checkTargetBranch({ github, context, core, dry }) {
core.info(
`Skipping checkTargetBranch: PR is from a development branch (${head})`,
)
await dismissReviews({
github,
context,
core,
dry,
reviewKey,
})
return
}
// Don't run on PRs against staging branches, wip branches, haskell-updates, etc.
@ -50,6 +60,15 @@ async function checkTargetBranch({ github, context, core, dry }) {
core.info(
`Skipping checkTargetBranch: PR is against a non-primary base branch (${base})`,
)
await dismissReviews({
github,
context,
core,
dry,
reviewKey,
})
return
}
@ -78,6 +97,7 @@ async function checkTargetBranch({ github, context, core, dry }) {
dry,
body,
event: 'REQUEST_CHANGES',
reviewKey,
})
throw new Error('This PR is against the wrong branch.')
@ -105,6 +125,7 @@ async function checkTargetBranch({ github, context, core, dry }) {
dry,
body,
event: 'REQUEST_CHANGES',
reviewKey,
})
throw new Error('This PR is against the wrong branch.')
@ -125,10 +146,18 @@ async function checkTargetBranch({ github, context, core, dry }) {
dry,
body,
event: 'COMMENT',
reviewKey,
})
} else {
// Any existing reviews were dismissed by commits.js
core.info('checkTargetBranch: this PR is against an appropriate branch.')
await dismissReviews({
github,
context,
core,
dry,
reviewKey,
})
}
}