Add target-directory-ignored-file-name

- Fixes #58
This commit is contained in:
Tim Daubenschütz 2022-08-24 14:25:13 +02:00
parent e775fb8544
commit 96f65f4ae1
2 changed files with 9 additions and 1 deletions

View File

@ -48,6 +48,10 @@ inputs:
description: '[Optional] The directory to wipe and replace in the target repository'
default: ''
required: false
target-directory-ignored-file-name:
description: '[Optional] A file name within the target directory that is not deleted'
default: ''
required: false
runs:
using: docker

View File

@ -15,6 +15,7 @@ DESTINATION_REPOSITORY_USERNAME="${8}"
TARGET_BRANCH="${9}"
COMMIT_MESSAGE="${10}"
TARGET_DIRECTORY="${11}"
TARGET_DIRECTORY_IGNORED_FILE_NAME="${12}"
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
then
@ -87,7 +88,10 @@ mv "$CLONE_DIR/.git" "$TEMP_DIR/.git"
ABSOLUTE_TARGET_DIRECTORY="$CLONE_DIR/$TARGET_DIRECTORY/"
echo "[+] Deleting $ABSOLUTE_TARGET_DIRECTORY"
rm -rf "$ABSOLUTE_TARGET_DIRECTORY"
$CURRENT_DIR="$(pwd)"
cd $ABSOLUTE_TARGET_DIRECTORY
ls | grep -v $TARGET_DIRECTORY_IGNORED_FILE_NAME | xargs rm -fr
cd $CURRENT_DIR
echo "[+] Creating (now empty) $ABSOLUTE_TARGET_DIRECTORY"
mkdir -p "$ABSOLUTE_TARGET_DIRECTORY"