mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2025-01-09 08:36:09 -07:00
Separated cloneRepo into 3 functions
This commit is contained in:
parent
9432cdfed9
commit
a2e083e01c
42
functions.sh
42
functions.sh
|
@ -38,25 +38,31 @@ setupGit() {
|
|||
git config --global user.name "$USER_NAME"
|
||||
}
|
||||
|
||||
cloneSimple() {
|
||||
git clone --single-branch --depth 1 --branch "$TARGET_BRANCH" "$GIT_CMD_REPOSITORY" "$CLONE_DIR"
|
||||
}
|
||||
|
||||
cloneCreateBranch() {
|
||||
if [ "$CREATE_TARGET_BRANCH_IF_NEEDED" = "true" ]
|
||||
then
|
||||
# Default branch of the repository is cloned. Later on the required branch
|
||||
# will be created
|
||||
git clone --single-branch --depth 1 "$GIT_CMD_REPOSITORY" "$CLONE_DIR"
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
cloneError() {
|
||||
echo "::error::Could not clone the destination repository. Command:"
|
||||
echo "::error::git clone --single-branch --branch $TARGET_BRANCH $GIT_CMD_REPOSITORY $CLONE_DIR"
|
||||
echo "::error::(Note that if they exist USER_NAME and API_TOKEN is redacted by GitHub)"
|
||||
echo "::error::Please verify that the target repository exist AND that it contains the destination branch name, and is accesible by the API_TOKEN_GITHUB OR SSH_DEPLOY_KEY"
|
||||
exit 1
|
||||
}
|
||||
|
||||
cloneRepo() {
|
||||
{
|
||||
git clone --single-branch --depth 1 --branch "$TARGET_BRANCH" "$GIT_CMD_REPOSITORY" "$CLONE_DIR"
|
||||
} || {
|
||||
if [ "$CREATE_TARGET_BRANCH_IF_NEEDED" = "true" ]
|
||||
then
|
||||
# Default branch of the repository is cloned. Later on the required branch
|
||||
# will be created
|
||||
git clone --single-branch --depth 1 "$GIT_CMD_REPOSITORY" "$CLONE_DIR"
|
||||
else
|
||||
false
|
||||
fi
|
||||
} || {
|
||||
echo "::error::Could not clone the destination repository. Command:"
|
||||
echo "::error::git clone --single-branch --branch $TARGET_BRANCH $GIT_CMD_REPOSITORY $CLONE_DIR"
|
||||
echo "::error::(Note that if they exist USER_NAME and API_TOKEN is redacted by GitHub)"
|
||||
echo "::error::Please verify that the target repository exist AND that it contains the destination branch name, and is accesible by the API_TOKEN_GITHUB OR SSH_DEPLOY_KEY"
|
||||
exit 1
|
||||
}
|
||||
cloneSimple || cloneCreateBranch || cloneError
|
||||
}
|
||||
|
||||
checkSource() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user