mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2025-01-10 09:09:00 -07:00
Support ALLOW_EMPTY_BRANCHES
This commit is contained in:
parent
47211c97b5
commit
15a6ec1f72
|
@ -16,6 +16,7 @@ TARGET_BRANCH="${9}"
|
||||||
COMMIT_MESSAGE="${10}"
|
COMMIT_MESSAGE="${10}"
|
||||||
TARGET_DIRECTORY="${11}"
|
TARGET_DIRECTORY="${11}"
|
||||||
CREATE_TARGET_BRANCH_IF_NEEDED="${12}"
|
CREATE_TARGET_BRANCH_IF_NEEDED="${12}"
|
||||||
|
ALLOW_EMPTY_BRANCHES="${13}"
|
||||||
|
|
||||||
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
||||||
then
|
then
|
||||||
|
@ -166,6 +167,10 @@ git add .
|
||||||
echo "[+] git status:"
|
echo "[+] git status:"
|
||||||
git status
|
git status
|
||||||
|
|
||||||
|
if [ "$ALLOW_EMPTY_BRANCHES" = "false" ] && [ "$(git diff --numstat | wc -l | xargs echo -n)" -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "[~] No changes have been made"
|
||||||
|
else
|
||||||
echo "[+] git diff-index:"
|
echo "[+] git diff-index:"
|
||||||
# git diff-index : to avoid doing the git commit failing if there are no changes to be commit
|
# git diff-index : to avoid doing the git commit failing if there are no changes to be commit
|
||||||
git diff-index --quiet HEAD || git commit --message "$COMMIT_MESSAGE"
|
git diff-index --quiet HEAD || git commit --message "$COMMIT_MESSAGE"
|
||||||
|
@ -173,3 +178,4 @@ git diff-index --quiet HEAD || git commit --message "$COMMIT_MESSAGE"
|
||||||
echo "[+] Pushing git commit"
|
echo "[+] Pushing git commit"
|
||||||
# --set-upstream: sets de branch when pushing to a branch that does not exist
|
# --set-upstream: sets de branch when pushing to a branch that does not exist
|
||||||
git push "$GIT_CMD_REPOSITORY" --set-upstream "$TARGET_BRANCH"
|
git push "$GIT_CMD_REPOSITORY" --set-upstream "$TARGET_BRANCH"
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user