43 lines
888 B
Bash
43 lines
888 B
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
echo "[sync] start $(date)"
|
|
|
|
# ===== config safety =====
|
|
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
|
|
|
|
# ===== 2. gitea repo =====
|
|
if [ ! -d iptv-gh-pages/.git ]; then
|
|
git clone https://${GITEA_HOST}/${GITEA_REPO}.git iptv-gh-pages
|
|
fi
|
|
|
|
# ===== 3. sync files =====
|
|
rsync -a --delete \
|
|
--exclude='.git' \
|
|
iptv/ iptv-gh-pages/
|
|
|
|
# ===== 4. commit & push =====
|
|
cd iptv-gh-pages
|
|
|
|
git add -A
|
|
git diff --cached --quiet && {
|
|
echo "[sync] no changes"
|
|
exit 0
|
|
}
|
|
|
|
git commit -m "sync $(date '+%Y-%m-%d %H:%M:%S')"
|
|
git push origin main
|
|
|
|
echo "[sync] done $(date)" |