This repository has been archived on 2025-06-09. You can view files and clone it, but cannot push or open issues or pull requests.
LaravelDockerPublisher/docker/entrypoint.git.sh

22 lines
572 B
Bash

#!/bin/bash
REPO_URL=${REPO_URL}
BRANCH=${BRANCH}
TARGET_DIR=/app/html
# 若資料夾為空則 clone
if [ -z "$(ls -A "$TARGET_DIR")" ]; then
echo "[git-worker] Cloning repository into $TARGET_DIR..."
git clone --branch "$BRANCH" "$REPO_URL" "$TARGET_DIR"
else
echo "[git-worker] Repository exists in $TARGET_DIR, skipping clone."
fi
# 定時 git pull
echo "[git-worker] Starting periodic git pull..."
while true; do
cd "$TARGET_DIR" || exit
echo "[git-worker] Pulling latest changes from $BRANCH..."
git pull origin "$BRANCH"
sleep 300
done