mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2024-12-22 08:06:10 -07:00
Allows pushing to target directory in target repo
Signed-off-by: Eliminater74 <eliminater74@gmail.com>
This commit is contained in:
parent
448b7dad95
commit
520a9d8c28
|
@ -29,6 +29,10 @@ inputs:
|
|||
description: '[Optional] commit message for the output repository. ORIGIN_COMMIT is replaced by the URL@commit in the origin repo'
|
||||
default: 'Update from ORIGIN_COMMIT'
|
||||
required: false
|
||||
target-directory:
|
||||
description: '[Optional] The directory to wipe and replace in the target repository'
|
||||
default: '.'
|
||||
required: false
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
|
@ -41,6 +45,7 @@ runs:
|
|||
- ${{ inputs.destination-repository-username }}
|
||||
- ${{ inputs.target-branch }}
|
||||
- ${{ inputs.commit-message }}
|
||||
- ${{ inputs.target-directory }}
|
||||
branding:
|
||||
icon: 'git-commit'
|
||||
color: 'green'
|
||||
|
|
|
@ -12,6 +12,7 @@ USER_NAME="$5"
|
|||
DESTINATION_REPOSITORY_USERNAME="$6"
|
||||
TARGET_BRANCH="$7"
|
||||
COMMIT_MESSAGE="$8"
|
||||
TARGET_DIRECTORY="$9"
|
||||
|
||||
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
||||
then
|
||||
|
@ -32,11 +33,18 @@ 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"
|
||||
ls -la "$CLONE_DIR"
|
||||
|
||||
TARGET_DIR=$(mktemp -d)
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
# This mv has been the easier way to be able to remove files that were there
|
||||
# but not anymore. Otherwise we had to remove the files from "$CLONE_DIR",
|
||||
# including "." and with the exception of ".git/"
|
||||
mv "$CLONE_DIR/.git" "$TARGET_DIR"
|
||||
mv "$CLONE_DIR/.git" "$TEMP_DIR/.git"
|
||||
|
||||
# Remove contents of target directory and create a new empty one
|
||||
rm -R "$CLONE_DIR/$TARGET_DIRECTORY/"
|
||||
mkdir "$CLONE_DIR/$TARGET_DIRECTORY"
|
||||
|
||||
mv "$TEMP_DIR/.git" "$CLONE_DIR/.git"
|
||||
|
||||
|
||||
#echo "[+] Deleting files from $DESTINATION_DIRECTORY in git repo $DESTINATION_REPOSITORY_NAME"
|
||||
#rm -rfv "$CLONE_DIR/$DESTINATION_DIRECTORY"/*
|
||||
|
@ -59,8 +67,8 @@ then
|
|||
fi
|
||||
|
||||
echo "Copy contents to target git repository"
|
||||
cp -ra "$SOURCE_DIRECTORY"/. "$TARGET_DIR"
|
||||
cd "$TARGET_DIR"
|
||||
cp -ra "$SOURCE_DIRECTORY"/. "$CLONE_DIR/$TARGET_DIRECTORY"
|
||||
cd "$CLONE_DIR"
|
||||
|
||||
echo "Files that will be pushed:"
|
||||
ls -la
|
||||
|
|
Loading…
Reference in New Issue
Block a user