9038c39afa
上次跑到 apt-get update 60s 超时(timeout 兜底生效)。原因: - Runner (ubuntu-latest) 用的是 archive.ubuntu.com / security.ubuntu.com - 之前的 sed 只匹配 deb.debian.org,对 Ubuntu 源根本没换 修改: - 换 Ubuntu 源到 mirrors.aliyun.com,兼容 legacy /etc/apt/sources.list、 deb822 .sources 和 sources.list.d/*.list 三种格式 - update timeout 60s → 90s,install 180s → 240s,给国内源一点余量 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
56 lines
2.2 KiB
YAML
56 lines
2.2 KiB
YAML
name: 部署到群晖
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: 安装 Docker CLI
|
|
run: |
|
|
# 大概率 gitea act_runner 已预装 docker,先探测(避免 apt 走国外源超时)
|
|
if command -v docker >/dev/null 2>&1; then
|
|
echo "Docker 已预装:$(docker --version)"
|
|
exit 0
|
|
fi
|
|
echo "Docker 未预装,换 Ubuntu 源到阿里云再 apt 安装"
|
|
# 兼容 legacy sources.list、deb822 .sources、以及 sources.list.d/*.list
|
|
sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g;s|security.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || true
|
|
sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g;s|security.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list.d/*.sources 2>/dev/null || true
|
|
sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g;s|security.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list.d/*.list 2>/dev/null || true
|
|
timeout 90 apt-get update -qq || { echo "apt-get update 超时/失败"; exit 1; }
|
|
timeout 240 apt-get install -y -qq docker.io || { echo "docker.io 安装超时/失败"; exit 1; }
|
|
docker --version
|
|
|
|
- name: 拉取代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 构建镜像
|
|
run: docker build -f Dockerfile.prod -t dysync:latest .
|
|
|
|
- name: 停止旧容器
|
|
run: |
|
|
docker stop dysync 2>/dev/null || true
|
|
docker rm dysync 2>/dev/null || true
|
|
|
|
- name: 启动新容器
|
|
run: |
|
|
docker run -d \
|
|
--name dysync \
|
|
--restart unless-stopped \
|
|
-p 10101:10101 \
|
|
-e TZ=Asia/Shanghai \
|
|
-e ASPNETCORE_ENVIRONMENT=Production \
|
|
-v /volume1/docker/apps/dysync/db:/app/db \
|
|
-v /volume1/docker/apps/dysync/logs:/app/logs \
|
|
-v /volume2/save/dysync/collect:/app/collect \
|
|
-v /volume2/save/dysync/favorite:/app/favorite \
|
|
-v /volume2/save/dysync/uper:/app/uper \
|
|
dysync:latest
|
|
|
|
- name: 部署完成提示
|
|
run: |
|
|
echo "✅ 部署完成,浏览器访问 http://192.168.1.66:10101 查看"
|