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

Support creating tags as a different user #33

Merged
merged 1 commit into from
May 2, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@ specific lables (`bump:major`,`bump:minor`,`bump:patch`).
inputs:
default_bump_level:
description: "Default bump level if labels are not attached [major,minor,patch]. Do nothing if it's empty"
required: false
dry_run:
description: "Do not actually tag next version if it's true"
required: false
github_token:
description: 'GITHUB_TOKEN to list pull requests and create tags'
default: '${{ github.token }}'
required: true
tag_as_user:
description: "Name to use when creating tags"
required: false
tag_as_email:
description: "Email address to use when creating tags"
required: false
outputs:
current_version:
description: "current version"
Expand Down
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ inputs:
description: "Do not actually tag next version if it's true"
required: false
github_token:
description: 'GITHUB_TOKEN to list pull requests'
description: 'GITHUB_TOKEN to list pull requests and create tags'
default: '${{ github.token }}'
required: true
tag_as_user:
description: "Name to use when creating tags"
required: false
tag_as_email:
description: "Email address to use when creating tags"
required: false
outputs:
current_version:
description: "current version"
Expand Down
14 changes: 11 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,20 @@ if [ "${ACTION}" = "labeled" ]; then
post_pre_status
else
# Set up Git.
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config user.name "${INPUT_TAG_AS_USER:-${GITHUB_ACTOR}}"
git config user.email "${INPUT_TAG_AS_EMAIL:-${GITHUB_ACTOR}@users.noreply.github.com}"

# Push the next tag.
git tag -a "${NEXT_VERSION}" -m "${TAG_MESSAGE}"
git push origin "${NEXT_VERSION}"

if [ -n "${INPUT_GITHUB_TOKEN}" ]; then
bare_server_url=$(echo "${GITHUB_SERVER_URL}" | sed 's#^.\+://##')
git -c "http.${GITHUB_SERVER_URL}/.extraheader=" \
push "https://x-access-token:${INPUT_GITHUB_TOKEN}@${bare_server_url}/${GITHUB_REPOSITORY}.git" \
"${NEXT_VERSION}"
else
git push origin "${NEXT_VERSION}"
fi

# Post post-bumpr status on merge.
post_post_status
Expand Down