Debain-repos/docker/gitPush.sh
2025-05-11 15:08:26 +02:00

35 lines
728 B
Bash

#!/bin/sh
set -e
WORKPTH="/etc/debmirror/"
REPO_DIR="$WORKPTH/Debain-repos"
REPO_URL="https://$GITEA_TOKEN@tea.shupogaki.org/YuruC3/Debain-repos.git"
# Clone repo only if it doesn't already exist
if [ ! -d "$REPO_DIR/.git" ]; then
echo "[$(date)] Cloning repository..."
git clone "$REPO_URL" "$REPO_DIR"
fi
cd "$REPO_DIR"
git config user.name "UpdateBot"
git config user.email "UpdateBot@localhost.local"
# pull changes
git pull
# check if modified
if git diff --quiet && git diff --cached --quiet; then
echo "No changes to commit."
# if yes, push
else
git add MirrorsV4 MirrorsV6
git commit -m "Auto-update mirror list on $(date -Iseconds)"
git push
echo "Changes pushed successfully."
fi