mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
ci/github-script/{reviews,check-target-branch,commits,prepare}: add sticky review support
This commit is contained in:
parent
3fb23e6837
commit
4447561c05
4 changed files with 177 additions and 43 deletions
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue