ci/github-script/prepare: classify branches

This commit is contained in:
Wolfgang Walther
2025-08-20 17:18:25 +02:00
parent 9caf455441
commit 4220a03df8
2 changed files with 19 additions and 23 deletions
+2 -22
View File
@@ -23,8 +23,8 @@ jobs:
prepare:
runs-on: ubuntu-24.04-arm
outputs:
baseBranch: ${{ steps.branches.outputs.base }}
headBranch: ${{ steps.branches.outputs.head }}
baseBranch: ${{ steps.prepare.outputs.base }}
headBranch: ${{ steps.prepare.outputs.head }}
mergedSha: ${{ steps.prepare.outputs.mergedSha }}
targetSha: ${{ steps.prepare.outputs.targetSha }}
systems: ${{ steps.prepare.outputs.systems }}
@@ -44,26 +44,6 @@ jobs:
core,
})
- name: Determine branch type
id: branches
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const { classify } = require('./ci/supportedBranches.js')
const { base, head } = context.payload.pull_request
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)
- name: Determine changed files
id: files
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
+17 -1
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(