mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2024-12-22 16:16:09 -07:00
Update entrypoint.sh
This commit is contained in:
parent
c3f0aa4db9
commit
280163351f
|
@ -12,6 +12,7 @@ USER_NAME="$5"
|
||||||
DESTINATION_REPOSITORY_USERNAME="$6"
|
DESTINATION_REPOSITORY_USERNAME="$6"
|
||||||
TARGET_BRANCH="$7"
|
TARGET_BRANCH="$7"
|
||||||
COMMIT_MESSAGE="$8"
|
COMMIT_MESSAGE="$8"
|
||||||
|
GITHUB_SERVER="$9"
|
||||||
|
|
||||||
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
||||||
then
|
then
|
||||||
|
@ -29,7 +30,7 @@ echo "Cloning destination git repository"
|
||||||
# Setup git
|
# Setup git
|
||||||
git config --global user.email "$USER_EMAIL"
|
git config --global user.email "$USER_EMAIL"
|
||||||
git config --global user.name "$USER_NAME"
|
git config --global user.name "$USER_NAME"
|
||||||
git clone --single-branch --branch "$TARGET_BRANCH" "https://$USER_NAME:$API_TOKEN_GITHUB@github.com/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR"
|
git clone --single-branch --branch "$TARGET_BRANCH" "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR"
|
||||||
ls -la "$CLONE_DIR"
|
ls -la "$CLONE_DIR"
|
||||||
|
|
||||||
TARGET_DIR=$(mktemp -d)
|
TARGET_DIR=$(mktemp -d)
|
||||||
|
@ -59,7 +60,7 @@ cd "$TARGET_DIR"
|
||||||
echo "Files that will be pushed:"
|
echo "Files that will be pushed:"
|
||||||
ls -la
|
ls -la
|
||||||
|
|
||||||
ORIGIN_COMMIT="https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
ORIGIN_COMMIT="https://$GITHUB_SERVER/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
||||||
COMMIT_MESSAGE="${COMMIT_MESSAGE/ORIGIN_COMMIT/$ORIGIN_COMMIT}"
|
COMMIT_MESSAGE="${COMMIT_MESSAGE/ORIGIN_COMMIT/$ORIGIN_COMMIT}"
|
||||||
COMMIT_MESSAGE="${COMMIT_MESSAGE/\$GITHUB_REF/$GITHUB_REF}"
|
COMMIT_MESSAGE="${COMMIT_MESSAGE/\$GITHUB_REF/$GITHUB_REF}"
|
||||||
|
|
||||||
|
@ -75,4 +76,4 @@ git diff-index --quiet HEAD || git commit --message "$COMMIT_MESSAGE"
|
||||||
|
|
||||||
echo "git push origin:"
|
echo "git push origin:"
|
||||||
# --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 "https://$USER_NAME:$API_TOKEN_GITHUB@github.com/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" --set-upstream "$TARGET_BRANCH"
|
git push "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" --set-upstream "$TARGET_BRANCH"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user