File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,15 @@ git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@${INPUT_ORGAN
3131git config --global user.name " ${GITHUB_ACTOR} "
3232git config --global user.email " ${GITHUB_ACTOR} @users.noreply.${INPUT_ORGANIZATION_DOMAIN} "
3333
34+ get_current_branch () {
35+ local branch
36+ branch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null || true)
37+ if [[ " ${branch} " == " HEAD" ]]; then
38+ branch=" "
39+ fi
40+ printf ' %s' " ${branch} "
41+ }
42+
3443# Get changed files
3544git add -A
3645FILES_CHANGED=$( git diff --staged --name-status)
4352SKIP_BRANCH_CREATION=false
4453if [[ -z ${FILES_CHANGED} && " ${INPUT_AMEND} " != " true" ]]; then
4554 SKIP_BRANCH_CREATION=true
46- BRANCH=" $( git symbolic-ref --short -q HEAD ) "
55+ BRANCH=" $( get_current_branch ) "
4756 echo -e " \n[INFO] No changes to commit and amend disabled; skipping branch creation."
4857fi
4958
5059if [[ " ${SKIP_BRANCH_CREATION} " != " true" ]]; then
5160 # Setting branch name
52- BRANCH=" ${INPUT_TARGET_BRANCH:- $(git symbolic-ref --short -q HEAD )} "
61+ BRANCH=" ${INPUT_TARGET_BRANCH:- $(get_current_branch )} "
5362 # Add timestamp to branch name
5463 if [[ " ${INPUT_ADD_TIMESTAMP} " == " true" ]]; then
5564 TIMESTAMP=$( date -u +" %Y-%m-%dT%H-%M-%SZ" )
You can’t perform that action at this time.
0 commit comments