From 189dd4bf5df6d3b59e206fa2f91fb89dd5ca1231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9D=A6?= Date: Mon, 31 Mar 2025 23:07:22 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=9B=B4=E6=96=B0=20.gitlab-ci.yml=20?= =?UTF-8?q?=E5=92=8C=20update=5Ffiles.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了 .gitlab-ci.yml 中的安全扫描配置 - 调整了 CI/CD 流水线的阶段 - 优化了 update_files.py 脚本的输出信息 - 添加了脚本执行开始的提示信息 - 修改了没有更新文件时的提示信息 --- .gitlab-ci.yml | 14 ++------------ update_files.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f23e0f1..560b502 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,6 @@ -# You can override the included template(s) by including variable overrides -# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings -# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/pipeline/#customization -# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings -# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings -# Note that environment variables can be set in several places -# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence -include: - - template: Security/Secret-Detection.gitlab-ci.yml - stages: - - test - auto-update - - build-web + - build-docs auto-update: # 需要配置 REPO_TOKEN 和 THE_REPO @@ -30,6 +19,7 @@ auto-update: - pip install pyyaml # 运行更新脚本 - python update_files.py + # build-web: # stage: build-web # image: node:22.14.0 diff --git a/update_files.py b/update_files.py index b85de4f..2e2d76c 100644 --- a/update_files.py +++ b/update_files.py @@ -1,9 +1,11 @@ #!/usr/bin/env python import os -import yaml import subprocess import sys +import yaml + + def download_file(url): """使用 curl 下载文件内容""" result = subprocess.run(["curl", "-s", url], capture_output=True, text=True) @@ -12,15 +14,17 @@ def download_file(url): return None return result.stdout + def main(): # 读取 list.yaml try: with open("list.yaml", "r", encoding="utf-8") as f: items = yaml.safe_load(f) except FileNotFoundError: - print("list.yaml 文件不存在。") + print("❌ list.yaml 文件不存在。") sys.exit(0) + print("🚀 开始更新文件") modified = False for item in items: @@ -72,7 +76,8 @@ def main(): subprocess.run(["git", "commit", "-m", commit_message], check=False) subprocess.run(["git", "push", "origin", "main"], check=True) else: - print("没有需要更新的文件。") + print("📦 没有需要更新的文件。") + if __name__ == "__main__": main()