mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2025-09-05 00:05:45 -06:00
mergeback
This commit is contained in:
parent
9e487f2958
commit
dd848d1c96
@ -48,7 +48,10 @@ inputs:
|
|||||||
description: '[Optional] The directory to wipe and replace in the target repository'
|
description: '[Optional] The directory to wipe and replace in the target repository'
|
||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
|
do-not-delete-list-file:
|
||||||
|
description: '[Optional] File path to a txt file containing each relative path that should be copied from the cloned dir, meaning its not wiped'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
runs:
|
runs:
|
||||||
using: docker
|
using: docker
|
||||||
image: Dockerfile
|
image: Dockerfile
|
||||||
@ -64,6 +67,7 @@ runs:
|
|||||||
- '${{ inputs.target-branch }}'
|
- '${{ inputs.target-branch }}'
|
||||||
- '${{ inputs.commit-message }}'
|
- '${{ inputs.commit-message }}'
|
||||||
- '${{ inputs.target-directory }}'
|
- '${{ inputs.target-directory }}'
|
||||||
|
- '${{ inputs.do-not-delete-list-file }}'
|
||||||
branding:
|
branding:
|
||||||
icon: git-commit
|
icon: git-commit
|
||||||
color: green
|
color: green
|
||||||
|
@ -15,7 +15,7 @@ DESTINATION_REPOSITORY_USERNAME="${8}"
|
|||||||
TARGET_BRANCH="${9}"
|
TARGET_BRANCH="${9}"
|
||||||
COMMIT_MESSAGE="${10}"
|
COMMIT_MESSAGE="${10}"
|
||||||
TARGET_DIRECTORY="${11}"
|
TARGET_DIRECTORY="${11}"
|
||||||
|
DO_NOT_DELETE_LIST_FILE="${12}"
|
||||||
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
||||||
then
|
then
|
||||||
DESTINATION_REPOSITORY_USERNAME="$DESTINATION_GITHUB_USERNAME"
|
DESTINATION_REPOSITORY_USERNAME="$DESTINATION_GITHUB_USERNAME"
|
||||||
@ -54,7 +54,6 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
CLONE_DIR=$(mktemp -d)
|
CLONE_DIR=$(mktemp -d)
|
||||||
|
|
||||||
echo "[+] Git version"
|
echo "[+] Git version"
|
||||||
@ -82,7 +81,22 @@ TEMP_DIR=$(mktemp -d)
|
|||||||
# but not anymore. Otherwise we had to remove the files from "$CLONE_DIR",
|
# but not anymore. Otherwise we had to remove the files from "$CLONE_DIR",
|
||||||
# including "." and with the exception of ".git/"
|
# including "." and with the exception of ".git/"
|
||||||
mv "$CLONE_DIR/.git" "$TEMP_DIR/.git"
|
mv "$CLONE_DIR/.git" "$TEMP_DIR/.git"
|
||||||
|
if [ -n "$DO_NOT_DELETE_LIST_FILE" ]
|
||||||
|
then
|
||||||
|
echo "[+] Using DO NOT DELETE LIST To INJECT INTO TMP"
|
||||||
|
cat < "$DO_NOT_DELETE_LIST_FILE" | while read -r line; do # 'line' is the variable name
|
||||||
|
if [ -n "$line" ]
|
||||||
|
then
|
||||||
|
if [ -f "$CLONE_DIR/$line" ]
|
||||||
|
then
|
||||||
|
cp -ra "$CLONE_DIR/$line" "$TEMP_DIR/$line"
|
||||||
|
echo "[+] Preserve file $line located, and copied to tmp dir"
|
||||||
|
else
|
||||||
|
echo "[+] Warning: preserve file $line Not found within cloned dir, skipping ahead"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
# $TARGET_DIRECTORY is '' by default
|
# $TARGET_DIRECTORY is '' by default
|
||||||
ABSOLUTE_TARGET_DIRECTORY="$CLONE_DIR/$TARGET_DIRECTORY/"
|
ABSOLUTE_TARGET_DIRECTORY="$CLONE_DIR/$TARGET_DIRECTORY/"
|
||||||
|
|
||||||
@ -99,6 +113,20 @@ echo "[+] Listing root Location"
|
|||||||
ls -al /
|
ls -al /
|
||||||
|
|
||||||
mv "$TEMP_DIR/.git" "$CLONE_DIR/.git"
|
mv "$TEMP_DIR/.git" "$CLONE_DIR/.git"
|
||||||
|
if [ -n "$DO_NOT_DELETE_LIST_FILE" ]
|
||||||
|
then
|
||||||
|
echo "[+] Using DO NOT DELETE LIST copy back from TMP"
|
||||||
|
cat < "$DO_NOT_DELETE_LIST_FILE" | while read -r line; do # 'line' is the variable name
|
||||||
|
if [ -n "$line" ]
|
||||||
|
then
|
||||||
|
if [ -f "$TEMP_DIR/$line" ]
|
||||||
|
then
|
||||||
|
echo "[+] Copying $line to TMP"
|
||||||
|
cp -ra "$TEMP_DIR/$line" "$CLONE_DIR/$line"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[+] List contents of $SOURCE_DIRECTORY"
|
echo "[+] List contents of $SOURCE_DIRECTORY"
|
||||||
ls "$SOURCE_DIRECTORY"
|
ls "$SOURCE_DIRECTORY"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user