mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
Restore the branch-suffix input
This commit is contained in:
parent
3c6aade49b
commit
8c01dce3ac
6 changed files with 65 additions and 17 deletions
|
@ -12,6 +12,7 @@ export interface Inputs {
|
|||
committer: string
|
||||
author: string
|
||||
branch: string
|
||||
branchSuffix: string
|
||||
base: string
|
||||
pushToFork: string
|
||||
title: string
|
||||
|
@ -107,6 +108,30 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
|||
}
|
||||
core.endGroup()
|
||||
|
||||
// Apply the branch suffix if set
|
||||
if (inputs.branchSuffix) {
|
||||
switch (inputs.branchSuffix) {
|
||||
case 'short-commit-hash':
|
||||
// Suffix with the short SHA1 hash
|
||||
inputs.branch = `${inputs.branch}-${await git.revParse('HEAD', [
|
||||
'--short'
|
||||
])}`
|
||||
break
|
||||
case 'timestamp':
|
||||
// Suffix with the current timestamp
|
||||
inputs.branch = `${inputs.branch}-${utils.secondsSinceEpoch()}`
|
||||
break
|
||||
case 'random':
|
||||
// Suffix with a 7 character random string
|
||||
inputs.branch = `${inputs.branch}-${utils.randomString()}`
|
||||
break
|
||||
default:
|
||||
throw new Error(
|
||||
`Branch suffix '${inputs.branchSuffix}' is not a valid value. Unable to continue.`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Output head branch
|
||||
core.info(
|
||||
`Pull request branch to create or update set to '${inputs.branch}'`
|
||||
|
|
|
@ -12,6 +12,7 @@ async function run(): Promise<void> {
|
|||
committer: core.getInput('committer'),
|
||||
author: core.getInput('author'),
|
||||
branch: core.getInput('branch'),
|
||||
branchSuffix: core.getInput('branch-suffix'),
|
||||
base: core.getInput('base'),
|
||||
pushToFork: core.getInput('push-to-fork'),
|
||||
title: core.getInput('title'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue