From ca1db67e8f30b3f93868e5c0b264dc7e203ae0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9D=A6?= Date: Wed, 19 Mar 2025 15:53:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8A=9F=E8=83=BD=E5=92=8C=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 39 +++++++++++++++++++++++++ README.md | 2 +- docker-compose/clash/docker-compose.yml | 12 ++++---- list.yaml | 14 +++++++++ 4 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 list.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a3ab23..3443832 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,3 +7,42 @@ # See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence include: - template: Security/Secret-Detection.gitlab-ci.yml + +stages: + - auto-update + +auto_update: + # 需要配置 REPO_TOKEN 和 THE_REPO + stage: auto-update + image: alpine:latest + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" # 通过定时任务触发 + before_script: + # 使用国内镜像源加速安装 + - echo "https://mirrors.aliyun.com/alpine/v3.18/main" > /etc/apk/repositories + - apk add --no-cache git openssh-client curl + script: | + echo "🛠️ 配置Git身份" + git config --global user.name "CI/CD" + git config --global user.email "cicd@sugarscat.cn" + echo "🔑 配置Git认证" + git remote remove origin || true + git remote add origin "https://oauth2:${REPO_TOKEN}@${THE_REPO}" + git fetch origin + git checkout -B main + + echo "🔁 Starting auto update..." + set +e # 忽略后续命令的错误 + for item in $(yq e '.list[]' list.yaml); do + file=$(echo $item | yq e '.file' -) + source=$(echo $item | yq e '.source' -) + echo "Downloading $source to $file" + curl -o "$file" "$source" || echo "❌️ Failed to download $source" + done + set -e # 恢复错误处理 + echo "Auto update completed." + + echo "🚀 推送回源仓库" + git add . + git commit -m "Auto update files" || echo "No changes to commit" + git push origin main \ No newline at end of file diff --git a/README.md b/README.md index 1845d1b..5bc6d9a 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ 自用 bash 脚本,用于快速搭建各种环境。 -注意更新时间,部分脚本可能已过期。 \ No newline at end of file +**注意更新时间,部分脚本可能已过期。** diff --git a/docker-compose/clash/docker-compose.yml b/docker-compose/clash/docker-compose.yml index 34a7a31..534e147 100644 --- a/docker-compose/clash/docker-compose.yml +++ b/docker-compose/clash/docker-compose.yml @@ -1,14 +1,12 @@ -version: '3' - services: - # Clash clash: - image: registry.cn-hangzhou.aliyuncs.com/37point2/clash:v1.18.0 + image: registry.cn-hangzhou.aliyuncs.com/37/clash:latest container_name: clash - volumes: - - ./data/config.yaml:/root/.config/clash/config.yaml + restart: always + network_mode: bridge ports: - "7890:7890/tcp" - "7890:7890/udp" - "9090:9090" - restart: always \ No newline at end of file + volumes: + - ./data/config.yaml:/root/.config/clash/config.yaml \ No newline at end of file diff --git a/list.yaml b/list.yaml new file mode 100644 index 0000000..f5866e1 --- /dev/null +++ b/list.yaml @@ -0,0 +1,14 @@ +# 需要自动更新的文件列表 +list: + - file: /docker/install.sh + source: https://raw.githubusercontent.com/docker/docker-install/master/install.sh + - file: /docker/debian/gpg + source: https://download.docker.com/linux/debian/gpg + - file: /docker/ubuntu/gpg + source: https://download.docker.com/linux/ubuntu/gpg + - file: /docker/raspbian/gpg + source: https://download.docker.com/linux/raspbian/gpg + - file: /docker/fedora/docker-ce.repo + source: https://download.docker.com/linux/fedora/docker-ce.repo + - file: /docker/centos/docker-ce.repo + source: https://download.docker.com/linux/centos/docker-ce.repo \ No newline at end of file