Skip to content

Commit f308953

Browse files
committed
Fixed issue deleting files that need to be deleted from the target repo
See cpina#16
1 parent f5a3797 commit f308953

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

entrypoint.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,12 @@ git config --global user.name "$DESTINATION_GITHUB_USERNAME"
2626
git clone --single-branch --branch "$TARGET_BRANCH" "https://$API_TOKEN_GITHUB@github.com/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR"
2727
ls -la "$CLONE_DIR"
2828

29-
echo "Cleaning destination repository of old files"
30-
# Deletes the contents of $CLONE_DIR with three exceptions (! -path "..."):
31-
# -Skips the $CLONE_DIR/ directory itself
32-
# -Skips the contents of $CLONE_DIR/.git/*
33-
# -Skips the $CLONE_DIR/.git
34-
find "$CLONE_DIR/" ! -path "$CLONE_DIR/" ! -path "$CLONE_DIR/.git/*" ! -path "$CLONE_DIR/.git" -exec rm -rf {} \;
35-
36-
echo "Contents of $CLONE_DIR after deleting everything but .git"
37-
ls -la "$CLONE_DIR"
29+
TARGET_DIR=$(mktemp -d)
30+
mv "$CLONE_DIR/.git" "$TARGET_DIR"
3831

3932
echo "Copying contents to git repo"
40-
cp -r "$SOURCE_DIRECTORY"/* "$CLONE_DIR"
41-
cd "$CLONE_DIR"
33+
cp -ra "$SOURCE_DIRECTORY"/. "$TARGET_DIR"
34+
cd "$TARGET_DIR"
4235

4336
echo "Files that will be pushed"
4437
ls -la

0 commit comments

Comments
 (0)