ci/github-script/prepare: classify branches

This commit is contained in:
Wolfgang Walther
2025-08-18 21:53:55 +02:00
parent 9caf455441
commit 4220a03df8
2 changed files with 19 additions and 23 deletions

View File

@@ -1,3 +1,5 @@
const { classify } = require('../supportedBranches.js')
module.exports = async ({ github, context, core }) => {
const pull_number = context.payload.pull_request.number
@@ -20,6 +22,8 @@ module.exports = async ({ github, context, core }) => {
continue
}
const { base, head } = prInfo
let mergedSha, targetSha
if (prInfo.mergeable) {
@@ -39,7 +43,7 @@ module.exports = async ({ github, context, core }) => {
targetSha = (
await github.rest.repos.compareCommitsWithBasehead({
...context.repo,
basehead: `${prInfo.base.sha}...${prInfo.head.sha}`,
basehead: `${base.sha}...${head.sha}`,
})
).data.merge_base_commit.sha
}
@@ -52,6 +56,18 @@ module.exports = async ({ github, context, core }) => {
core.setOutput('systems', require('../supportedSystems.json'))
const baseClassification = classify(base.ref)
core.setOutput('base', baseClassification)
core.info('base classification:', baseClassification)
const headClassification =
base.repo.full_name === head.repo.full_name
? classify(head.ref)
: // PRs from forks are always considered WIP.
{ type: ['wip'] }
core.setOutput('head', headClassification)
core.info('head classification:', headClassification)
return
}
throw new Error(