add
This commit is contained in:
@@ -88,7 +88,6 @@ jobs:
|
|||||||
GITHUB_WORKFLOW: ${{ github.workflow }}
|
GITHUB_WORKFLOW: ${{ github.workflow }}
|
||||||
GITHUB_RUN_NUMBER: ${{ github.run_number }}
|
GITHUB_RUN_NUMBER: ${{ github.run_number }}
|
||||||
GITHUB_RUN_ID: ${{ github.run_id }}
|
GITHUB_RUN_ID: ${{ github.run_id }}
|
||||||
GITHUB_STEP_SUMMARY: ""
|
|
||||||
run: |
|
run: |
|
||||||
if [ -z "${{ github.event.inputs.force_push_message }}" ]; then
|
if [ -z "${{ github.event.inputs.force_push_message }}" ]; then
|
||||||
export FORCE_PUSH_MESSAGE="False"
|
export FORCE_PUSH_MESSAGE="False"
|
||||||
@@ -121,7 +120,6 @@ jobs:
|
|||||||
echo "Workflow Number: ${{ github.run_number }}"
|
echo "Workflow Number: ${{ github.run_number }}"
|
||||||
echo "Workflow ID: ${{ github.run_id }}"
|
echo "Workflow ID: ${{ github.run_id }}"
|
||||||
echo "Beijing Time: $BEIJING_TIME" | tee time.txt
|
echo "Beijing Time: $BEIJING_TIME" | tee time.txt
|
||||||
echo "### Hello world! :rocket:" >> $GITHUB_STEP_SUMMARY
|
|
||||||
|
|
||||||
# 删除__pycache__文件夹
|
# 删除__pycache__文件夹
|
||||||
- name: Delete __pycache__ folder
|
- name: Delete __pycache__ folder
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ github_workflow = os.environ.get("GITHUB_WORKFLOW")
|
|||||||
github_run_number = os.environ.get("GITHUB_RUN_NUMBER")
|
github_run_number = os.environ.get("GITHUB_RUN_NUMBER")
|
||||||
github_run_id = os.environ.get("GITHUB_RUN_ID")
|
github_run_id = os.environ.get("GITHUB_RUN_ID")
|
||||||
beijing_time = os.environ.get("BEIJING_TIME")
|
beijing_time = os.environ.get("BEIJING_TIME")
|
||||||
github_step_summary = os.environ.get("GITHUB_STEP_SUMMARY")
|
|
||||||
|
|
||||||
os.environ["GITHUB_STEP_SUMMARY"] = "test_txt"
|
|
||||||
|
|
||||||
# 将字符串转换为布尔值
|
# 将字符串转换为布尔值
|
||||||
force_push_message = force_push_message == "True"
|
force_push_message = force_push_message == "True"
|
||||||
|
|
||||||
|
# 初始化运行日志
|
||||||
|
run_log = ""
|
||||||
|
|
||||||
|
|
||||||
# MD5加密
|
# MD5加密
|
||||||
def md5_encrypt(string):
|
def md5_encrypt(string):
|
||||||
@@ -322,7 +322,7 @@ grades_updated_push_integrated_send_info = (
|
|||||||
|
|
||||||
# 如果是第一次运行,则提示程序运行成功
|
# 如果是第一次运行,则提示程序运行成功
|
||||||
if run_count == 2:
|
if run_count == 2:
|
||||||
print(first_run_text)
|
run_log += f"{first_run_text}\n"
|
||||||
|
|
||||||
# 推送信息
|
# 推送信息
|
||||||
first_run_text_response_text = send_message(
|
first_run_text_response_text = send_message(
|
||||||
@@ -339,20 +339,20 @@ if run_count == 2:
|
|||||||
first_run_text_response_dict.pop("data")
|
first_run_text_response_dict.pop("data")
|
||||||
|
|
||||||
# 输出响应内容
|
# 输出响应内容
|
||||||
print(first_run_text_response_dict)
|
run_log += f"{first_run_text_response_dict}\n"
|
||||||
else:
|
else:
|
||||||
# 如果非第一次运行,则输出成绩信息
|
# 如果非第一次运行,则输出成绩信息
|
||||||
if grade:
|
if grade:
|
||||||
print(f"新成绩:{encrypted_integrated_grade_info}")
|
run_log += f"新成绩:{encrypted_integrated_grade_info}\n"
|
||||||
print(f"旧成绩:{old_grade_content}")
|
run_log += f"旧成绩:{old_grade_content}\n"
|
||||||
else:
|
else:
|
||||||
print("成绩为空")
|
run_log += "成绩为空\n"
|
||||||
print("------")
|
run_log += "------\n"
|
||||||
|
|
||||||
# 对grade.txt和old_grade.txt两个文件的内容进行比对,输出成绩是否更新
|
# 对grade.txt和old_grade.txt两个文件的内容进行比对,输出成绩是否更新
|
||||||
if grade_content != old_grade_content or force_push_message:
|
if grade_content != old_grade_content or force_push_message:
|
||||||
# 判断是否选中了强制推送信息
|
# 判断是否选中了强制推送信息
|
||||||
print("强制推送信息" if force_push_message else "成绩已更新")
|
run_log += f"{'强制推送信息' if force_push_message else '成绩已更新'}\n"
|
||||||
|
|
||||||
# 推送信息
|
# 推送信息
|
||||||
response_text = send_message(
|
response_text = send_message(
|
||||||
@@ -369,9 +369,9 @@ else:
|
|||||||
response_dict.pop("data")
|
response_dict.pop("data")
|
||||||
|
|
||||||
# 输出响应内容
|
# 输出响应内容
|
||||||
print(response_dict)
|
run_log += f"{response_dict}\n"
|
||||||
else:
|
else:
|
||||||
print("成绩未更新")
|
run_log += "成绩未更新"
|
||||||
|
|
||||||
# 更新info.txt
|
# 更新info.txt
|
||||||
with open(info_file_path, "r") as info_file:
|
with open(info_file_path, "r") as info_file:
|
||||||
@@ -380,6 +380,15 @@ with open(info_file_path, "r") as info_file:
|
|||||||
with open("info.txt", "w") as info_file:
|
with open("info.txt", "w") as info_file:
|
||||||
info_file.write(encrypted_info)
|
info_file.write(encrypted_info)
|
||||||
|
|
||||||
|
# 输出运行日志
|
||||||
|
print(run_log)
|
||||||
|
|
||||||
|
# 将 run_log 写入到 GitHub Actions 的环境文件中
|
||||||
|
github_step_summary_path = os.environ.get('GITHUB_STEP_SUMMARY')
|
||||||
|
if github_step_summary_path:
|
||||||
|
with open(github_step_summary_path, 'w', encoding='utf-8') as file:
|
||||||
|
file.write(run_log)
|
||||||
|
|
||||||
# 删除 __pycache__ 缓存目录及其内容
|
# 删除 __pycache__ 缓存目录及其内容
|
||||||
current_directory = os.getcwd()
|
current_directory = os.getcwd()
|
||||||
cache_folder = os.path.join(current_directory, "__pycache__")
|
cache_folder = os.path.join(current_directory, "__pycache__")
|
||||||
|
|||||||
Reference in New Issue
Block a user