refactor: 优化同步慢的问题
This commit is contained in:
parent
d65f11a96c
commit
6c121f1094
55
sync.sh
55
sync.sh
@ -1,40 +1,43 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "[1] update iptv-org repo"
|
echo "[sync] start $(date)"
|
||||||
|
|
||||||
if [ ! -d iptv ]; then
|
# ===== config safety =====
|
||||||
git clone https://github.com/iptv-org/iptv.git
|
git config --global user.name "iptv-sync"
|
||||||
|
git config --global user.email "bot@local"
|
||||||
|
git config --global http.version HTTP/1.1
|
||||||
|
|
||||||
|
# ===== 1. github gh-pages =====
|
||||||
|
if [ ! -d iptv/.git ]; then
|
||||||
|
git clone --depth 1 -b gh-pages https://github.com/iptv-org/iptv.git iptv
|
||||||
|
else
|
||||||
|
cd iptv
|
||||||
|
git fetch origin gh-pages
|
||||||
|
git reset --hard origin/gh-pages
|
||||||
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd iptv
|
# ===== 2. gitea repo =====
|
||||||
git fetch origin
|
if [ ! -d iptv-gh-pages/.git ]; then
|
||||||
git checkout gh-pages
|
|
||||||
git reset --hard origin/gh-pages
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
echo "[2] update gitea repo"
|
|
||||||
|
|
||||||
if [ ! -d iptv-gh-pages ]; then
|
|
||||||
git clone https://${GITEA_HOST}/${GITEA_REPO}.git iptv-gh-pages
|
git clone https://${GITEA_HOST}/${GITEA_REPO}.git iptv-gh-pages
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ===== 3. sync files =====
|
||||||
|
rsync -a --delete \
|
||||||
|
--exclude='.git' \
|
||||||
|
iptv/ iptv-gh-pages/
|
||||||
|
|
||||||
|
# ===== 4. commit & push =====
|
||||||
cd iptv-gh-pages
|
cd iptv-gh-pages
|
||||||
git pull origin main || true
|
|
||||||
|
|
||||||
echo "[3] sync files"
|
git add -A
|
||||||
|
git diff --cached --quiet && {
|
||||||
# 清空旧内容(保留 .git)
|
echo "[sync] no changes"
|
||||||
find . -mindepth 1 -maxdepth 1 ! -name ".git" -exec rm -rf {} +
|
exit 0
|
||||||
|
}
|
||||||
cp -r ../iptv/* .
|
|
||||||
|
|
||||||
echo "[4] commit & push"
|
|
||||||
|
|
||||||
git add .
|
|
||||||
|
|
||||||
git commit -m "sync: $(date '+%Y-%m-%d %H:%M:%S')" || echo "no changes"
|
|
||||||
|
|
||||||
|
git commit -m "sync $(date '+%Y-%m-%d %H:%M:%S')"
|
||||||
git push origin main
|
git push origin main
|
||||||
|
|
||||||
echo "[done]"
|
echo "[sync] done $(date)"
|
||||||
Loading…
x
Reference in New Issue
Block a user