-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
34 lines (30 loc) · 1.02 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
PROJECT_DIRECTORY="/app/${DIRECTORY_NAME:-project}"
SUBFOLDER=${SUBFOLDER_PATH:-""} # Fetch the sub-folder path from an environment variable
mkdir -p ~/.ssh
git config --global pull.rebase ${GIT_PULL_REBASE:-false}
if [ ! -d "$PROJECT_DIRECTORY/.git" ]; then
echo "Cloning the repository: $REPO_URL"
mkdir -p $PROJECT_DIRECTORY
ssh-keyscan ${GIT_URL:-github.com} >> ~/.ssh/known_hosts
git init $PROJECT_DIRECTORY
cd $PROJECT_DIRECTORY
git remote add origin $REPO_URL
git pull origin ${GIT_BRANCH:-main}
rsync -vazC $PROJECT_DIRECTORY/$SUBFOLDER ${DESTINATION_PATH:-/app/sync}
fi
if [[ "$PWD" != "$PROJECT_DIRECTORY" ]]
then
cd "$PROJECT_DIRECTORY"
fi
while true; do
echo "Syncing the repository every $INTERVAL seconds"
git -C $PROJECT_DIRECTORY pull origin ${GIT_BRANCH:-main}
git clean -fd
sleep ${INTERVAL:-10}
if [ -z "$SUBFOLDER" ]; then
rsync -vazC $PROJECT_DIRECTORY/ ${DESTINATION_PATH:-/app/sync}
else
rsync -vazC $PROJECT_DIRECTORY/$SUBFOLDER ${DESTINATION_PATH:-/app/sync}
fi
done