Skip to content

Commit 425a06a

Browse files
authored
Merge pull request #33 from jordemort/use-token-for-push
Support creating tags as a different user
2 parents 1cb2e23 + cd64f1f commit 425a06a

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,20 @@ specific lables (`bump:major`,`bump:minor`,`bump:patch`).
1919
inputs:
2020
default_bump_level:
2121
description: "Default bump level if labels are not attached [major,minor,patch]. Do nothing if it's empty"
22+
required: false
2223
dry_run:
2324
description: "Do not actually tag next version if it's true"
25+
required: false
26+
github_token:
27+
description: 'GITHUB_TOKEN to list pull requests and create tags'
28+
default: '${{ github.token }}'
29+
required: true
30+
tag_as_user:
31+
description: "Name to use when creating tags"
32+
required: false
33+
tag_as_email:
34+
description: "Email address to use when creating tags"
35+
required: false
2436
outputs:
2537
current_version:
2638
description: "current version"

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ inputs:
99
description: "Do not actually tag next version if it's true"
1010
required: false
1111
github_token:
12-
description: 'GITHUB_TOKEN to list pull requests'
12+
description: 'GITHUB_TOKEN to list pull requests and create tags'
1313
default: '${{ github.token }}'
1414
required: true
15+
tag_as_user:
16+
description: "Name to use when creating tags"
17+
required: false
18+
tag_as_email:
19+
description: "Email address to use when creating tags"
20+
required: false
1521
outputs:
1622
current_version:
1723
description: "current version"

entrypoint.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,20 @@ if [ "${ACTION}" = "labeled" ]; then
161161
post_pre_status
162162
else
163163
# Set up Git.
164-
git config user.name "${GITHUB_ACTOR}"
165-
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
164+
git config user.name "${INPUT_TAG_AS_USER:-${GITHUB_ACTOR}}"
165+
git config user.email "${INPUT_TAG_AS_EMAIL:-${GITHUB_ACTOR}@users.noreply.github.com}"
166166

167167
# Push the next tag.
168168
git tag -a "${NEXT_VERSION}" -m "${TAG_MESSAGE}"
169-
git push origin "${NEXT_VERSION}"
169+
170+
if [ -n "${INPUT_GITHUB_TOKEN}" ]; then
171+
bare_server_url=$(echo "${GITHUB_SERVER_URL}" | sed 's#^.\+://##')
172+
git -c "http.${GITHUB_SERVER_URL}/.extraheader=" \
173+
push "https://x-access-token:${INPUT_GITHUB_TOKEN}@${bare_server_url}/${GITHUB_REPOSITORY}.git" \
174+
"${NEXT_VERSION}"
175+
else
176+
git push origin "${NEXT_VERSION}"
177+
fi
170178

171179
# Post post-bumpr status on merge.
172180
post_post_status

0 commit comments

Comments
 (0)