diff --git a/update_files.py b/update_files.py index 189c41b..31be79a 100644 --- a/update_files.py +++ b/update_files.py @@ -21,7 +21,7 @@ def main(): print("list.yaml 文件不存在。") sys.exit(0) - modified = False + modified = True for item in items: file_path = item.get("file") @@ -65,6 +65,7 @@ def main(): token = os.environ.get("REPO_TOKEN") new_repo_url = repo_url.replace("https://", f"https://oauth2:{token}@") subprocess.run(["git", "remote", "set-url", "origin", new_repo_url], check=True) + subprocess.run(["git", "checkout", "-B", "main"], check=True) subprocess.run(["git", "add", "."], check=True) commit_message = "自动更新:从 list.yaml 下载最新文件" # 如果没有变更,则 git commit 会返回非零状态,可用 || true 处理