Remove the branch option and replace with just head-branch and base-branch

This commit is contained in:
Josh Dales
2023-01-28 22:30:05 -05:00
parent 2daf35ae4b
commit 231de6bc24
3 changed files with 38 additions and 18 deletions

View File

@@ -3,6 +3,38 @@ import * as github from '@actions/github';
type BranchBase = 'base' | 'head';
export function toMatchConfigWithBranches(config: any) {
if (!config['head-branch'] || config['base-branch']) {
return config;
}
const branchConfig = {
headBranch: config['head-branch'],
baseBranch: config['base-branch']
};
if (branchConfig.headBranch) {
const patterns = branchConfig.headBranch;
if (typeof patterns === 'string') {
branchConfig.headBranch = [patterns];
}
}
if (branchConfig.baseBranch) {
const patterns = branchConfig.baseBranch;
if (typeof patterns === 'string') {
branchConfig.baseBranch = [patterns];
}
}
return {
...config,
['head-branch']: undefined,
['base-branch']: undefined,
...branchConfig
};
}
export function getBranchName(branchBase?: BranchBase): string | undefined {
const pullRequest = github.context.payload.pull_request;
if (!pullRequest) {