Skip to content

Commit 0e4f5f6

Browse files
authored
feat: add tag_push input and tag_pushed output (#374)
1 parent d67ae5f commit 0e4f5f6

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ inputs:
5252
tag:
5353
description: Arguments for the git tag command (the tag name always needs to be the first word not preceded by a hyphen)
5454
required: false
55+
tag_push:
56+
description: Arguments for the git push --tags command (any additional argument will be added after --tags)
57+
required: false
5558

5659
# Input not required from the user
5760
github_token:
@@ -70,6 +73,8 @@ outputs:
7073
description: Whether the action has pushed to the remote.
7174
tagged:
7275
description: Whether the action has created a tag.
76+
tag_pushed:
77+
description: Whether the action has pushed a tag.
7378

7479
runs:
7580
using: node12

lib/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/io.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface InputTypes {
1717
push: string
1818
remove: string | undefined
1919
tag: string | undefined
20+
tag_push: string | undefined
2021

2122
github_token: string | undefined
2223
}
@@ -28,6 +29,7 @@ interface OutputTypes {
2829
commit_sha: string | undefined
2930
pushed: 'true' | 'false'
3031
tagged: 'true' | 'false'
32+
tag_pushed: 'true' | 'false'
3133
}
3234
export type output = keyof OutputTypes
3335

@@ -36,7 +38,8 @@ export const outputs: OutputTypes = {
3638
commit_long_sha: undefined,
3739
commit_sha: undefined,
3840
pushed: 'false',
39-
tagged: 'false'
41+
tagged: 'false',
42+
tag_pushed: 'false'
4043
}
4144
// Setup default output values
4245
Object.entries(outputs).forEach(([name, value]) => core.setOutput(name, value))

src/main.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -149,26 +149,12 @@ core.info(`Running in ${baseDir}`)
149149
if (getInput('tag')) {
150150
core.info('> Pushing tags to repo...')
151151
await git
152-
.pushTags('origin', undefined, (e, d?) => log(undefined, e || d))
153-
.catch(() => {
154-
core.info(
155-
'> Tag push failed: deleting remote tag and re-pushing...'
156-
)
157-
return git
158-
.push(
159-
undefined,
160-
undefined,
161-
{
162-
'--delete': null,
163-
origin: null,
164-
[matchGitArgs(getInput('tag') || '').filter(
165-
(w) => !w.startsWith('-')
166-
)[0]]: null
167-
},
168-
log
169-
)
170-
.pushTags('origin', undefined, log)
152+
.pushTags('origin', matchGitArgs(getInput('tag_push') || ''))
153+
.then((data) => {
154+
setOutput('tag_pushed', 'true')
155+
return log(null, data)
171156
})
157+
.catch((err) => core.setFailed(err))
172158
} else core.info('> No tags to push.')
173159
} else core.info('> Not pushing anything.')
174160

0 commit comments

Comments
 (0)