Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tag_push input and tag_pushed output #374

Merged
merged 1 commit into from Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions action.yml
Expand Up @@ -52,6 +52,9 @@ inputs:
tag:
description: Arguments for the git tag command (the tag name always needs to be the first word not preceded by a hyphen)
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
github_token:
Expand All @@ -70,6 +73,8 @@ outputs:
description: Whether the action has pushed to the remote.
tagged:
description: Whether the action has created a tag.
tag_pushed:
description: Whether the action has pushed a tag.

runs:
using: node12
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/io.ts
Expand Up @@ -17,6 +17,7 @@ interface InputTypes {
push: string
remove: string | undefined
tag: string | undefined
tag_push: string | undefined

github_token: string | undefined
}
Expand All @@ -28,6 +29,7 @@ interface OutputTypes {
commit_sha: string | undefined
pushed: 'true' | 'false'
tagged: 'true' | 'false'
tag_pushed: 'true' | 'false'
}
export type output = keyof OutputTypes

Expand All @@ -36,7 +38,8 @@ export const outputs: OutputTypes = {
commit_long_sha: undefined,
commit_sha: undefined,
pushed: 'false',
tagged: 'false'
tagged: 'false',
tag_pushed: 'false'
}
// Setup default output values
Object.entries(outputs).forEach(([name, value]) => core.setOutput(name, value))
Expand Down
24 changes: 5 additions & 19 deletions src/main.ts
Expand Up @@ -149,26 +149,12 @@ core.info(`Running in ${baseDir}`)
if (getInput('tag')) {
core.info('> Pushing tags to repo...')
await git
.pushTags('origin', undefined, (e, d?) => log(undefined, e || d))
.catch(() => {
core.info(
'> Tag push failed: deleting remote tag and re-pushing...'
)
return git
.push(
undefined,
undefined,
{
'--delete': null,
origin: null,
[matchGitArgs(getInput('tag') || '').filter(
(w) => !w.startsWith('-')
)[0]]: null
},
log
)
.pushTags('origin', undefined, log)
.pushTags('origin', matchGitArgs(getInput('tag_push') || ''))
.then((data) => {
setOutput('tag_pushed', 'true')
return log(null, data)
})
.catch((err) => core.setFailed(err))
} else core.info('> No tags to push.')
} else core.info('> Not pushing anything.')

Expand Down