File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,13 @@ inputs:
48
48
description : ' [Optional] The directory to wipe and replace in the target repository'
49
49
default : ' '
50
50
required : false
51
-
51
+ create-target-branch-if-needed :
52
+ type : boolean
53
+ description : >-
54
+ [Optional] create target branch if not exist. Defaults to `false`
55
+ default : false
56
+ required : false
57
+
52
58
runs :
53
59
using : docker
54
60
image : Dockerfile
64
70
- ' ${{ inputs.target-branch }}'
65
71
- ' ${{ inputs.commit-message }}'
66
72
- ' ${{ inputs.target-directory }}'
73
+ - ' ${{ inputs.create-target-branch-if-needed }}'
67
74
branding :
68
75
icon : git-commit
69
76
color : green
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ DESTINATION_REPOSITORY_USERNAME="${8}"
15
15
TARGET_BRANCH=" ${9} "
16
16
COMMIT_MESSAGE=" ${10} "
17
17
TARGET_DIRECTORY=" ${11} "
18
+ CREATE_TARGET_BRANCH_IF_NEEDED=" ${12} "
18
19
19
20
if [ -z " $DESTINATION_REPOSITORY_USERNAME " ]
20
21
then
@@ -70,6 +71,12 @@ git config --global user.name "$USER_NAME"
70
71
71
72
{
72
73
git clone --single-branch --depth 1 --branch " $TARGET_BRANCH " " $GIT_CMD_REPOSITORY " " $CLONE_DIR "
74
+ } || {
75
+ if [ " $CREATE_TARGET_BRANCH_IF_NEEDED " = ' true' ] ; then
76
+ git clone --single-branch --depth 1 " $GIT_CMD_REPOSITORY " " $CLONE_DIR "
77
+ else
78
+ false
79
+ fi
73
80
} || {
74
81
echo " ::error::Could not clone the destination repository. Command:"
75
82
echo " ::error::git clone --single-branch --branch $TARGET_BRANCH $GIT_CMD_REPOSITORY $CLONE_DIR "
@@ -137,6 +144,11 @@ echo "[+] Set directory is safe ($CLONE_DIR)"
137
144
# TODO: review before releasing it as a version
138
145
git config --global --add safe.directory " $CLONE_DIR "
139
146
147
+
148
+ if [ " $CREATE_TARGET_BRANCH_IF_NEEDED " = ' true' ] ; then
149
+ git checkout -b " $TARGET_BRANCH "
150
+ fi
151
+
140
152
echo " [+] Adding git commit"
141
153
git add .
142
154
You can’t perform that action at this time.
0 commit comments