Skip to content

Commit 2294890

Browse files
authored
Merge pull request #95 from fritz-trawa/55-actor-of-pushing-to-branch-should-be-configurable
feat(#55): add ACTOR input parameter
2 parents 899b309 + abecbc8 commit 2294890

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

action.yml

+33-30
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
name: 'Bump and changelog using commitizen'
2-
description: 'Create a commit bumping the version of your project and creating a changelog file'
1+
name: "Bump and changelog using commitizen"
2+
description: "Create a commit bumping the version of your project and creating a changelog file"
33
runs:
4-
using: 'docker'
5-
image: 'Dockerfile'
4+
using: "docker"
5+
image: "Dockerfile"
66
branding:
7-
icon: 'git-commit'
8-
color: 'purple'
7+
icon: "git-commit"
8+
color: "purple"
99
outputs:
1010
version:
11-
description: 'New version'
11+
description: "New version"
1212
inputs:
1313
working_directory:
14-
description: 'Change to this directory before running'
14+
description: "Change to this directory before running"
1515
required: false
1616
dry_run:
17-
description: 'Run without creating commit, output to stdout'
17+
description: "Run without creating commit, output to stdout"
1818
required: false
1919
commit:
20-
description: 'If true a commit is created containing the bump changes'
20+
description: "If true a commit is created containing the bump changes"
2121
required: false
2222
default: "true"
2323
push:
24-
description: 'If true the bump commit is pushed to the remote repository'
24+
description: "If true the bump commit is pushed to the remote repository"
2525
required: false
2626
default: "true"
2727
merge:
@@ -31,62 +31,62 @@ inputs:
3131
required: false
3232
default: "false"
3333
prerelease:
34-
description: 'Set as prerelease version'
34+
description: "Set as prerelease version"
3535
required: false
3636
devrelease:
37-
description: 'Non-negative integer for dev. release'
37+
description: "Non-negative integer for dev. release"
3838
required: false
3939
local_version:
40-
description: 'Bump only the local version portion'
40+
description: "Bump only the local version portion"
4141
required: false
4242
default: "false"
4343
changelog:
44-
description: 'Create changelog when bumping the version'
44+
description: "Create changelog when bumping the version"
4545
default: "true"
4646
required: false
4747
github_token:
4848
description: 'Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}'
4949
required: false
5050
repository:
51-
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})'
52-
default: ''
51+
description: "Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})"
52+
default: ""
5353
required: false
5454
branch:
55-
description: 'Destination branch to push changes'
55+
description: "Destination branch to push changes"
5656
required: false
57-
default: ''
57+
default: ""
5858
extra_requirements:
59-
description: 'Extra commitizen dependencies like your custom plugins or rules'
59+
description: "Extra commitizen dependencies like your custom plugins or rules"
6060
required: false
61-
default: ''
61+
default: ""
6262
changelog_increment_filename:
63-
description: 'Filename to store the incremented generated changelog. This is different to changelog as it only contains the changes for the just generated version'
63+
description: "Filename to store the incremented generated changelog. This is different to changelog as it only contains the changes for the just generated version"
6464
required: false
6565
git_redirect_stderr:
66-
description: 'Redirect git output to stderr. Useful if you do not want git output in your changelog'
66+
description: "Redirect git output to stderr. Useful if you do not want git output in your changelog"
6767
required: false
6868
default: "false"
6969
git_name:
70-
description: 'Name used to configure git (for git operations)'
70+
description: "Name used to configure git (for git operations)"
7171
required: false
72-
default: 'github-actions[bot]'
72+
default: "github-actions[bot]"
7373
git_email:
74-
description: 'Email address used to configure git (for git operations)'
74+
description: "Email address used to configure git (for git operations)"
7575
required: false
76-
default: 'github-actions[bot]@users.noreply.github.com'
76+
default: "github-actions[bot]@users.noreply.github.com"
7777
commitizen_version:
78-
description: 'Specify the version to be used by commitizen'
78+
description: "Specify the version to be used by commitizen"
7979
required: false
8080
default: latest
8181
no_raise:
8282
description: "Don't raise the given comma-delimited exit codes"
8383
required: false
84-
default: '21'
84+
default: "21"
8585
increment:
8686
description: "Manually specify the desired increment"
8787
required: false
8888
check_consistency:
89-
default: 'false'
89+
default: "false"
9090
description: "check consistency among versions defined in commitizen configuration and version_files"
9191
required: false
9292
gpg_sign:
@@ -100,3 +100,6 @@ inputs:
100100
description: "If true, prints debug output to GitHub Actions stdout."
101101
required: false
102102
default: "false"
103+
actor:
104+
description: "The account that will be used to perform git operations, defaults to the GITHUB_ACTOR"
105+
required: false

entrypoint.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ else
8787
echo "${CZ_CMD[@]}"
8888
"${CZ_CMD[@]}"
8989
fi
90+
if [[ $INPUT_ACTOR ]]; then
91+
ACTOR=$INPUT_ACTOR
92+
else
93+
ACTOR=$GITHUB_ACTOR
94+
fi
9095

9196
REV="$(cz version --project)"
9297
if [[ $REV == "$PREV_REV" ]]; then
@@ -101,15 +106,15 @@ INPUT_BRANCH="${INPUT_BRANCH:-$CURRENT_BRANCH}"
101106
INPUT_REPOSITORY="${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}"
102107

103108
echo "Repository: ${INPUT_REPOSITORY}"
104-
echo "Actor: ${GITHUB_ACTOR}"
109+
echo "Actor: ${ACTOR}"
105110

106111
if [[ $INPUT_PUSH == 'true' ]]; then
107112
if [[ $INPUT_MERGE != 'true' && $GITHUB_EVENT_NAME == 'pull_request' ]]; then
108113
echo "Refusing to push on pull_request event since that would merge the pull request." >&2
109114
echo "You probably want to run on push to your default branch instead." >&2
110115
else
111116
echo "Pushing to branch..."
112-
REMOTE_REPO="https://${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@${GITHUB_DOMAIN}/${INPUT_REPOSITORY}.git"
117+
REMOTE_REPO="https://${ACTOR}:${INPUT_GITHUB_TOKEN}@${GITHUB_DOMAIN}/${INPUT_REPOSITORY}.git"
113118
git pull "$REMOTE_REPO" "$INPUT_BRANCH"
114119
git push "$REMOTE_REPO" "HEAD:${INPUT_BRANCH}" --tags
115120
fi

0 commit comments

Comments
 (0)