fix: stabilise staging sync
This commit is contained in:
@@ -57,7 +57,9 @@ services:
|
||||
[ -f /run/secrets/GIT_TOKEN ] && export GIT_TOKEN="$(cat /run/secrets/GIT_TOKEN)" || true
|
||||
|
||||
# Fix Git ownership issue
|
||||
# Ensure Git treats the mounted repository as safe regardless of owner
|
||||
git config --global --add safe.directory /var/www/html 2>/dev/null || true
|
||||
git config --system --add safe.directory /var/www/html 2>/dev/null || true
|
||||
|
||||
# Git Clone/Pull functionality
|
||||
if [ -n "$GIT_REPOSITORY_URL" ]; then
|
||||
@@ -84,7 +86,7 @@ services:
|
||||
fi
|
||||
TEMP_CLONE="${GIT_TARGET_DIR}.tmp"
|
||||
rm -rf "$TEMP_CLONE" 2>/dev/null || true
|
||||
if git clone --branch "$GIT_BRANCH" --depth 1 "$GIT_URL_WITH_AUTH" "$TEMP_CLONE"; then
|
||||
if git -c safe.directory=/var/www/html clone --branch "$GIT_BRANCH" --depth 1 "$GIT_URL_WITH_AUTH" "$TEMP_CLONE"; then
|
||||
find "$GIT_TARGET_DIR" -mindepth 1 -maxdepth 1 ! -name "storage" -exec rm -rf {} \; 2>/dev/null || true
|
||||
find "$TEMP_CLONE" -mindepth 1 -maxdepth 1 ! -name "." ! -name ".." -exec mv {} "$GIT_TARGET_DIR/" \; 2>/dev/null || true
|
||||
rm -rf "$TEMP_CLONE" 2>/dev/null || true
|
||||
@@ -93,9 +95,9 @@ services:
|
||||
else
|
||||
echo "🔄 Pulling latest changes from $GIT_BRANCH..."
|
||||
cd "$GIT_TARGET_DIR"
|
||||
git fetch origin "$GIT_BRANCH" || echo "⚠️ Git fetch failed"
|
||||
git reset --hard "origin/$GIT_BRANCH" || echo "⚠️ Git reset failed"
|
||||
git clean -fd || true
|
||||
git -c safe.directory=/var/www/html fetch origin "$GIT_BRANCH" || echo "⚠️ Git fetch failed"
|
||||
git -c safe.directory=/var/www/html reset --hard "origin/$GIT_BRANCH" || echo "⚠️ Git reset failed"
|
||||
git -c safe.directory=/var/www/html clean -fd || true
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
|
||||
Reference in New Issue
Block a user