Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f3894a8b0 | ||
|
|
6c121f1094 | ||
|
|
d65f11a96c | ||
|
|
9fa26f3b26 |
5
.env
Normal file
5
.env
Normal file
@ -0,0 +1,5 @@
|
||||
GITEA_HOST=gitea.proxy.liyanyan.work
|
||||
GITEA_USER=liyy
|
||||
GITEA_TOKEN=xxxxxxxxxxxxxxxx
|
||||
GITEA_REPO=liyy/iptv-gh-pages
|
||||
SYNC_INTERVAL=1800
|
||||
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
FROM alpine:3.20
|
||||
|
||||
RUN apk add --no-cache \
|
||||
git \
|
||||
bash \
|
||||
ca-certificates\
|
||||
rsync
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY sync.sh /workspace/sync.sh
|
||||
COPY entrypoint.sh /workspace/entrypoint.sh
|
||||
|
||||
RUN chmod +x /workspace/*.sh
|
||||
|
||||
CMD ["/workspace/entrypoint.sh"]
|
||||
24
README.md
24
README.md
@ -0,0 +1,24 @@
|
||||
# IPTV Sync Mirror (gh-pages → Gitea)
|
||||
|
||||
基于 Docker 的自动同步工具,将 :contentReference[oaicite:0]{index=0} 的 gh-pages 静态文件同步到 Gitea,用于构建稳定 IPTV 镜像源。
|
||||
|
||||
---
|
||||
|
||||
## 功能
|
||||
|
||||
- 定时拉取 iptv-org gh-pages
|
||||
- 同步到 Gitea 仓库
|
||||
- 只保留静态文件
|
||||
- 自动 push 更新
|
||||
|
||||
---
|
||||
|
||||
## 架构
|
||||
|
||||
GitHub gh-pages → Docker sync → Gitea repo → 静态访问
|
||||
|
||||
---
|
||||
|
||||
## 注意
|
||||
|
||||
启动之前需要修改 `.env`文件的`GITEA_TOKEN`字段。
|
||||
9
docker-compose.yaml
Normal file
9
docker-compose.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
iptv-sync:
|
||||
build: .
|
||||
container_name: iptv-sync
|
||||
restart: always
|
||||
env_file:
|
||||
- .env
|
||||
27
entrypoint.sh
Normal file
27
entrypoint.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "[init] setting git auth"
|
||||
|
||||
cat <<EOF > /root/.netrc
|
||||
machine ${GITEA_HOST}
|
||||
login ${GITEA_USER}
|
||||
password ${GITEA_TOKEN}
|
||||
EOF
|
||||
|
||||
chmod 600 /root/.netrc
|
||||
|
||||
git config --global user.name "iptv-sync-bot"
|
||||
git config --global user.email "bot@local"
|
||||
|
||||
echo "[init] start loop sync"
|
||||
|
||||
while true
|
||||
do
|
||||
echo "=========================="
|
||||
echo "[sync start] $(date)"
|
||||
/workspace/sync.sh
|
||||
echo "[sync end] $(date)"
|
||||
echo "sleep ${SYNC_INTERVAL}s"
|
||||
sleep ${SYNC_INTERVAL}
|
||||
done
|
||||
43
sync.sh
Normal file
43
sync.sh
Normal file
@ -0,0 +1,43 @@
|
||||
#!/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)"
|
||||
Loading…
x
Reference in New Issue
Block a user