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