#!/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