@@ -26,6 +26,9 @@ inputs:
|
|||||||
description: The flag used on the pull strategy
|
description: The flag used on the pull strategy
|
||||||
required: false
|
required: false
|
||||||
default: '--no-rebase'
|
default: '--no-rebase'
|
||||||
|
push:
|
||||||
|
description: Whether to push the commit to the repo
|
||||||
|
required: false
|
||||||
remove:
|
remove:
|
||||||
description: Arguments for the git rm command
|
description: Arguments for the git rm command
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
|||||||
// WARNING: this file is auto-generated by scripts/inputs.ts (npm run inputs), any manual edit will be overwritten.
|
// WARNING: this file is auto-generated by scripts/inputs.ts (npm run inputs), any manual edit will be overwritten.
|
||||||
|
|
||||||
export type Input = 'add' | 'author_name' | 'author_email' | 'branch' | 'cwd' | 'message' | 'pull_strategy' | 'remove' | 'signoff' | 'tag'
|
export type Input = 'add' | 'author_name' | 'author_email' | 'branch' | 'cwd' | 'message' | 'pull_strategy' | 'push' | 'remove' | 'signoff' | 'tag'
|
||||||
|
|||||||
67
src/main.ts
67
src/main.ts
@@ -66,21 +66,23 @@ console.log(`Running in ${baseDir}`);
|
|||||||
await git.tag(getInput('tag').split(' '), log)
|
await git.tag(getInput('tag').split(' '), log)
|
||||||
} else info('> No tag info provided.')
|
} else info('> No tag info provided.')
|
||||||
|
|
||||||
info('> Pushing commit to repo...')
|
if (getInput('push')) {
|
||||||
await git.push('origin', getInput('branch'), { '--set-upstream': null }, log)
|
info('> Pushing commit to repo...')
|
||||||
|
await git.push('origin', getInput('branch'), { '--set-upstream': null }, log)
|
||||||
|
|
||||||
if (getInput('tag')) {
|
if (getInput('tag')) {
|
||||||
info('> Pushing tags to repo...')
|
info('> Pushing tags to repo...')
|
||||||
await git.pushTags('origin', (e, d?) => log(undefined, e || d)).catch(() => {
|
await git.pushTags('origin', (e, d?) => log(undefined, e || d)).catch(() => {
|
||||||
info('> Tag push failed: deleting remote tag and re-pushing...')
|
info('> Tag push failed: deleting remote tag and re-pushing...')
|
||||||
return git.push(undefined, undefined, {
|
return git.push(undefined, undefined, {
|
||||||
'--delete': null,
|
'--delete': null,
|
||||||
'origin': null,
|
'origin': null,
|
||||||
[getInput('tag').split(' ').filter(w => !w.startsWith('-'))[0]]: null
|
[getInput('tag').split(' ').filter(w => !w.startsWith('-'))[0]]: null
|
||||||
}, log)
|
}, log)
|
||||||
.pushTags('origin', log)
|
.pushTags('origin', log)
|
||||||
})
|
})
|
||||||
} else info('> No tags to push.')
|
} else info('> No tags to push.')
|
||||||
|
} else info('> Not pushing anything.')
|
||||||
|
|
||||||
endGroup()
|
endGroup()
|
||||||
info('> Task completed.')
|
info('> Task completed.')
|
||||||
@@ -175,13 +177,32 @@ async function checkInputs() {
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region signoff
|
// #region signoff
|
||||||
if (getInput('signoff')) try {
|
if (getInput('signoff')) {
|
||||||
const parsed = JSON.parse(getInput('signoff'))
|
const parsed = parseBool(getInput('signoff'))
|
||||||
if (typeof parsed == 'boolean' && !parsed)
|
|
||||||
|
if (parsed === undefined)
|
||||||
|
throw new Error(`"${getInput('signoff')}" is not a valid value for the 'signoff' input: only "true" and "false" are allowed.`)
|
||||||
|
|
||||||
|
if (!parsed)
|
||||||
setInput('signoff', undefined)
|
setInput('signoff', undefined)
|
||||||
|
|
||||||
debug(`Current signoff option: ${getInput('signoff')} (${typeof getInput('signoff')})`)
|
debug(`Current signoff option: ${getInput('signoff')} (${typeof getInput('signoff')})`)
|
||||||
} catch {
|
}
|
||||||
throw new Error(`"${getInput('signoff')}" is not a valid value for the 'signoff' input: only "true" and "false" are allowed.`)
|
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region push
|
||||||
|
setDefault('push', 'true')
|
||||||
|
if (getInput('push')) { // It's just to scope the parsed constant
|
||||||
|
const parsed = parseBool(getInput('push'))
|
||||||
|
|
||||||
|
if (parsed === undefined)
|
||||||
|
throw new Error(`"${getInput('push')}" is not a valid value for the 'push' input: only "true" and "false" are allowed.`)
|
||||||
|
|
||||||
|
if (!parsed)
|
||||||
|
setInput('push', undefined)
|
||||||
|
|
||||||
|
debug(`Current push option: ${getInput('push')} (${typeof getInput('push')})`)
|
||||||
}
|
}
|
||||||
// #endregion
|
// #endregion
|
||||||
}
|
}
|
||||||
@@ -190,6 +211,14 @@ function getInput(name: Input) {
|
|||||||
return getInputCore(name)
|
return getInputCore(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseBool(value: any) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(value)
|
||||||
|
if (typeof parsed == 'boolean')
|
||||||
|
return parsed
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
|
|
||||||
function log(err: any | Error, data?: any) {
|
function log(err: any | Error, data?: any) {
|
||||||
if (data) console.log(data)
|
if (data) console.log(data)
|
||||||
if (err) error(err)
|
if (err) error(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user