mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2025-09-03 15:35:45 -06:00
Merge 8d707905ec57c46621904e5c05d26468be390c91 into 7c1bd869f38327ce403753fc2a5769e26cacb5ac
This commit is contained in:
commit
57e16aeef3
@ -54,6 +54,12 @@ inputs:
|
||||
[Optional] create target branch if not exist. Defaults to `false`
|
||||
default: false
|
||||
required: false
|
||||
allow-empty-branches:
|
||||
type: boolean
|
||||
description: >-
|
||||
[Optional] allow empty branches to be pushed. Defaults to `true`
|
||||
default: true
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: docker
|
||||
@ -71,6 +77,7 @@ runs:
|
||||
- '${{ inputs.commit-message }}'
|
||||
- '${{ inputs.target-directory }}'
|
||||
- '${{ inputs.create-target-branch-if-needed }}'
|
||||
- '${{ inputs.allow-empty-branches }}'
|
||||
branding:
|
||||
icon: git-commit
|
||||
color: green
|
||||
|
@ -16,6 +16,7 @@ TARGET_BRANCH="${9}"
|
||||
COMMIT_MESSAGE="${10}"
|
||||
TARGET_DIRECTORY="${11}"
|
||||
CREATE_TARGET_BRANCH_IF_NEEDED="${12}"
|
||||
ALLOW_EMPTY_BRANCHES="${13}"
|
||||
|
||||
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
||||
then
|
||||
@ -166,10 +167,15 @@ git add .
|
||||
echo "[+] git status:"
|
||||
git status
|
||||
|
||||
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 --quiet HEAD || git commit --message "$COMMIT_MESSAGE"
|
||||
|
||||
echo "[+] Pushing git commit"
|
||||
# --set-upstream: sets de branch when pushing to a branch that does not exist
|
||||
git push "$GIT_CMD_REPOSITORY" --set-upstream "$TARGET_BRANCH"
|
||||
if [ "$ALLOW_EMPTY_BRANCHES" = "false" ] && [ "$(git status --short | wc -l | xargs echo -n)" = "0" ]
|
||||
then
|
||||
echo "[~] No changes have been made"
|
||||
else
|
||||
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 --quiet HEAD || git commit --message "$COMMIT_MESSAGE"
|
||||
|
||||
echo "[+] Pushing git commit"
|
||||
# --set-upstream: sets de branch when pushing to a branch that does not exist
|
||||
git push "$GIT_CMD_REPOSITORY" --set-upstream "$TARGET_BRANCH"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user