From 121802c5b31264e17e3c3e7fd8069a4c4f55e844 Mon Sep 17 00:00:00 2001 From: NianBroken Date: Wed, 7 Feb 2024 20:10:24 +0800 Subject: [PATCH] add --- .github/workflows/main.yml | 7 ++++--- main.py | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 482c2b1..40da0cb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,8 +50,8 @@ jobs: # 创建一个备份目录,并将当前目录中的所有.txt文件复制到备份目录 - name: Backup local .txt files run: | - mkdir backup - cp *.txt backup/ || echo "No .txt files to backup" + mkdir -p backup + cp -r *.txt backup/ || echo "No .txt files to backup" # 将上游main分支的更改强制推送到当前main分支 - name: Force push changes from upstream to current main branch @@ -70,7 +70,7 @@ jobs: # 从备份目录将.txt文件还原到当前目录,然后删除备份目录 - name: Restore local .txt files and delete backup run: | - cp backup/*.txt . || echo "No .txt files to restore" + cp -r backup/*.txt . || echo "No .txt files to restore" rm -rf backup # 运行主程序main.py @@ -88,6 +88,7 @@ jobs: GITHUB_WORKFLOW: ${{ github.workflow }} GITHUB_RUN_NUMBER: ${{ github.run_number }} GITHUB_RUN_ID: ${{ github.run_id }} + GITHUB_STEP_SUMMARY: "" run: | if [ -z "${{ github.event.inputs.force_push_message }}" ]; then export FORCE_PUSH_MESSAGE="False" diff --git a/main.py b/main.py index 62a3096..61f44f3 100644 --- a/main.py +++ b/main.py @@ -23,6 +23,7 @@ github_workflow = os.environ.get("GITHUB_WORKFLOW") github_run_number = os.environ.get("GITHUB_RUN_NUMBER") github_run_id = os.environ.get("GITHUB_RUN_ID") beijing_time = os.environ.get("BEIJING_TIME") +step_summary = os.environ.get("GITHUB_STEP_SUMMARY") # 将字符串转换为布尔值 force_push_message = force_push_message == "True" @@ -372,6 +373,13 @@ else: else: print("成绩未更新") + +# 修改环境变量的值 +step_summary += "This is a test message.\n" + +# 设置环境变量的值 +os.environ["GITHUB_STEP_SUMMARY"] = step_summary + # 更新info.txt with open(info_file_path, "r") as info_file: info_file_content = info_file.read()