From daeff4a3c1aed50ca3629432b9dec3207f1d95b8 Mon Sep 17 00:00:00 2001 From: YuruC3 <98943911+YuruC3@@users.noreply.github.com> Date: Sat, 24 May 2025 10:22:28 +0200 Subject: [PATCH] Version 2.1.0 --- docker/Dockerfile | 2 +- docker/gitPush.sh | 39 ++++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 5db9211..ae73be4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -12,7 +12,7 @@ RUN apk update && \ RUN mkdir /etc/debmirror WORKDIR /etc/debmirror/ -RUN git clone https://tea.shupogaki.org/YuruC3/Repo-IP-lists && \ +RUN git clone https://tea.shupogaki.org/YuruC3/Repo-IP-lists.git && \ ln -s /etc/debmirror/Repo-IP-lists/MirrorListV4 /etc/debmirror/MirrorListV4 && \ ln -s /etc/debmirror/Repo-IP-lists/MirrorListV6 /etc/debmirror/MirrorListV6 && \ ln -s /etc/debmirror/Repo-IP-lists/OPNS_MirrorListV4 /etc/debmirror/OPNS_MirrorListV4 && \ diff --git a/docker/gitPush.sh b/docker/gitPush.sh index f79280c..6662f61 100644 --- a/docker/gitPush.sh +++ b/docker/gitPush.sh @@ -5,39 +5,48 @@ WORKPTH="/etc/debmirror/" REPO_DIR="$WORKPTH/Repo-IP-lists" REPO_URL="${GITURLPROTO}://${GITURL}/${GITREPOPATH}" - # 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" +# Make sure remote includes token for pushing git remote set-url origin "https://${GITEA_TOKEN}@${GITURL}/${GITREPOPATH}" +# Check for unpushed commits +if [ "$(git rev-list --count origin/main..HEAD)" -gt 0 ]; then + echo "Found commits to push" + git push + echo "Pushed successfully" +else + echo "No new commits to push" +fi + +# Set identity git config user.name "UpdateBot" git config user.email "UpdateBot@localhost.local" -# stage files +# Stage and commit any local changes before pulling git add MirrorListV4 MirrorListV6 OPNS_MirrorListV4 OPNS_MirrorListV6 - -# If anything to commit locally, commit it now -if ! git diff --quiet --cached; then +if ! git diff --cached --quiet; then echo "[$(date)] Committing local changes before pulling" git commit -m "Auto-commit before pull on $(date -Iseconds)" fi -# Now pull the latest +# Pull latest updates git pull --rebase --autostash -# Commit and push only if there's anything new staged -if git diff --quiet; then - echo "[$(date)] No changes to commit." -else - git commit -a -m "Auto-update mirror list on $(date -Iseconds)" --quiet - git push --quiet - echo "[$(date)] Changes pushed successfully." -fi +# Stage files again in case they changed due to updated script +git add MirrorListV4 MirrorListV6 OPNS_MirrorListV4 OPNS_MirrorListV6 +# Commit and push only if there's something to commit +if ! git diff --cached --quiet; then + git commit -m "Auto-update mirror list on $(date -Iseconds)" + git push + echo "[$(date)] Changes pushed successfully." +else + echo "[$(date)] No new changes to commit." +fi