feat: add tag_push input and tag_pushed output (#374)
This commit is contained in:
@@ -52,6 +52,9 @@ inputs:
|
|||||||
tag:
|
tag:
|
||||||
description: Arguments for the git tag command (the tag name always needs to be the first word not preceded by a hyphen)
|
description: Arguments for the git tag command (the tag name always needs to be the first word not preceded by a hyphen)
|
||||||
required: false
|
required: false
|
||||||
|
tag_push:
|
||||||
|
description: Arguments for the git push --tags command (any additional argument will be added after --tags)
|
||||||
|
required: false
|
||||||
|
|
||||||
# Input not required from the user
|
# Input not required from the user
|
||||||
github_token:
|
github_token:
|
||||||
@@ -70,6 +73,8 @@ outputs:
|
|||||||
description: Whether the action has pushed to the remote.
|
description: Whether the action has pushed to the remote.
|
||||||
tagged:
|
tagged:
|
||||||
description: Whether the action has created a tag.
|
description: Whether the action has created a tag.
|
||||||
|
tag_pushed:
|
||||||
|
description: Whether the action has pushed a tag.
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: node12
|
using: node12
|
||||||
|
|||||||
4
lib/index.js
generated
4
lib/index.js
generated
File diff suppressed because one or more lines are too long
@@ -17,6 +17,7 @@ interface InputTypes {
|
|||||||
push: string
|
push: string
|
||||||
remove: string | undefined
|
remove: string | undefined
|
||||||
tag: string | undefined
|
tag: string | undefined
|
||||||
|
tag_push: string | undefined
|
||||||
|
|
||||||
github_token: string | undefined
|
github_token: string | undefined
|
||||||
}
|
}
|
||||||
@@ -28,6 +29,7 @@ interface OutputTypes {
|
|||||||
commit_sha: string | undefined
|
commit_sha: string | undefined
|
||||||
pushed: 'true' | 'false'
|
pushed: 'true' | 'false'
|
||||||
tagged: 'true' | 'false'
|
tagged: 'true' | 'false'
|
||||||
|
tag_pushed: 'true' | 'false'
|
||||||
}
|
}
|
||||||
export type output = keyof OutputTypes
|
export type output = keyof OutputTypes
|
||||||
|
|
||||||
@@ -36,7 +38,8 @@ export const outputs: OutputTypes = {
|
|||||||
commit_long_sha: undefined,
|
commit_long_sha: undefined,
|
||||||
commit_sha: undefined,
|
commit_sha: undefined,
|
||||||
pushed: 'false',
|
pushed: 'false',
|
||||||
tagged: 'false'
|
tagged: 'false',
|
||||||
|
tag_pushed: 'false'
|
||||||
}
|
}
|
||||||
// Setup default output values
|
// Setup default output values
|
||||||
Object.entries(outputs).forEach(([name, value]) => core.setOutput(name, value))
|
Object.entries(outputs).forEach(([name, value]) => core.setOutput(name, value))
|
||||||
|
|||||||
24
src/main.ts
24
src/main.ts
@@ -149,26 +149,12 @@ core.info(`Running in ${baseDir}`)
|
|||||||
if (getInput('tag')) {
|
if (getInput('tag')) {
|
||||||
core.info('> Pushing tags to repo...')
|
core.info('> Pushing tags to repo...')
|
||||||
await git
|
await git
|
||||||
.pushTags('origin', undefined, (e, d?) => log(undefined, e || d))
|
.pushTags('origin', matchGitArgs(getInput('tag_push') || ''))
|
||||||
.catch(() => {
|
.then((data) => {
|
||||||
core.info(
|
setOutput('tag_pushed', 'true')
|
||||||
'> Tag push failed: deleting remote tag and re-pushing...'
|
return log(null, data)
|
||||||
)
|
|
||||||
return git
|
|
||||||
.push(
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
'--delete': null,
|
|
||||||
origin: null,
|
|
||||||
[matchGitArgs(getInput('tag') || '').filter(
|
|
||||||
(w) => !w.startsWith('-')
|
|
||||||
)[0]]: null
|
|
||||||
},
|
|
||||||
log
|
|
||||||
)
|
|
||||||
.pushTags('origin', undefined, log)
|
|
||||||
})
|
})
|
||||||
|
.catch((err) => core.setFailed(err))
|
||||||
} else core.info('> No tags to push.')
|
} else core.info('> No tags to push.')
|
||||||
} else core.info('> Not pushing anything.')
|
} else core.info('> Not pushing anything.')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user