Version 2.1.0
This commit is contained in:
parent
f572e9f10e
commit
daeff4a3c1
@ -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 && \
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user