feat: 添加自动更新功能和文件列表配置
This commit is contained in:
@@ -7,3 +7,42 @@
|
|||||||
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
|
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
|
||||||
include:
|
include:
|
||||||
- template: Security/Secret-Detection.gitlab-ci.yml
|
- 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
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
自用 bash 脚本,用于快速搭建各种环境。
|
自用 bash 脚本,用于快速搭建各种环境。
|
||||||
|
|
||||||
注意更新时间,部分脚本可能已过期。
|
**注意更新时间,部分脚本可能已过期。**
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
version: '3'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Clash
|
|
||||||
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
|
container_name: clash
|
||||||
volumes:
|
restart: always
|
||||||
- ./data/config.yaml:/root/.config/clash/config.yaml
|
network_mode: bridge
|
||||||
ports:
|
ports:
|
||||||
- "7890:7890/tcp"
|
- "7890:7890/tcp"
|
||||||
- "7890:7890/udp"
|
- "7890:7890/udp"
|
||||||
- "9090:9090"
|
- "9090:9090"
|
||||||
restart: always
|
volumes:
|
||||||
|
- ./data/config.yaml:/root/.config/clash/config.yaml
|
||||||
14
list.yaml
Normal file
14
list.yaml
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user