mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2024-12-22 08:06:10 -07:00
Merge branch 'patch-1' into main
This commit is contained in:
commit
df5ac1b335
|
@ -18,6 +18,10 @@ inputs:
|
|||
user-email:
|
||||
description: Email for the git commit
|
||||
required: true
|
||||
github-server:
|
||||
description: 'Github server'
|
||||
default: 'github.com'
|
||||
required: false
|
||||
user-name:
|
||||
description: >-
|
||||
[Optional] Name for the git commit. Defaults to the destination
|
||||
|
@ -44,6 +48,7 @@ inputs:
|
|||
description: '[Optional] The directory to wipe and replace in the target repository'
|
||||
default: .
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: docker
|
||||
image: Dockerfile
|
||||
|
@ -52,6 +57,7 @@ runs:
|
|||
- '${{ inputs.source-directory }}'
|
||||
- '${{ inputs.destination-github-username }}'
|
||||
- '${{ inputs.destination-repository-name }}'
|
||||
- '${{ inputs.github-server }}'
|
||||
- '${{ inputs.user-email }}'
|
||||
- '${{ inputs.user-name }}'
|
||||
- '${{ inputs.destination-repository-username }}'
|
||||
|
|
|
@ -8,12 +8,13 @@ SOURCE_BEFORE_DIRECTORY="$1"
|
|||
SOURCE_DIRECTORY="$2"
|
||||
DESTINATION_GITHUB_USERNAME="$3"
|
||||
DESTINATION_REPOSITORY_NAME="$4"
|
||||
USER_EMAIL="$5"
|
||||
USER_NAME="$6"
|
||||
DESTINATION_REPOSITORY_USERNAME="$7"
|
||||
TARGET_BRANCH="$8"
|
||||
COMMIT_MESSAGE="$9"
|
||||
TARGET_DIRECTORY="${10}"
|
||||
GITHUB_SERVER="$5"
|
||||
USER_EMAIL="$6"
|
||||
USER_NAME="$7"
|
||||
DESTINATION_REPOSITORY_USERNAME="$8"
|
||||
TARGET_BRANCH="$9"
|
||||
COMMIT_MESSAGE="${10}"
|
||||
TARGET_DIRECTORY="${11}"
|
||||
|
||||
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
||||
then
|
||||
|
@ -31,7 +32,7 @@ echo "[+] Cloning destination git repository $DESTINATION_REPOSITORY_NAME"
|
|||
# Setup git
|
||||
git config --global user.email "$USER_EMAIL"
|
||||
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"
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
|
@ -90,7 +91,7 @@ cd "$CLONE_DIR"
|
|||
echo "[+] Files that will be pushed"
|
||||
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/\$GITHUB_REF/$GITHUB_REF}"
|
||||
|
||||
|
@ -106,4 +107,4 @@ 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 "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