Delete synchronized upstream branch assignments and modify check grade assignments.
This commit is contained in:
@@ -21,70 +21,10 @@ on:
|
|||||||
- "False"
|
- "False"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# 同步上游分支
|
|
||||||
SyncFork:
|
|
||||||
name: SyncFork
|
|
||||||
|
|
||||||
# 在最新版的Ubuntu系统上运行
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
# 定义SyncFork的变量
|
|
||||||
outputs:
|
|
||||||
MAIN_YML_FILES_INCONSISTENT: ${{ steps.compare_main_yml_files.outputs.MAIN_YML_FILES_INCONSISTENT }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# 使用GitHub Actions提供的动作来检出代码库
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@main
|
|
||||||
|
|
||||||
- name: Configure Git
|
|
||||||
run: |
|
|
||||||
# 配置Git用户信息
|
|
||||||
git config --global user.email "actions@github.com"
|
|
||||||
git config --global user.name "GitHub Actions"
|
|
||||||
|
|
||||||
- name: Fetch upstream changes
|
|
||||||
run: |
|
|
||||||
# 添加上游仓库作为远程仓库,并获取上游仓库的main分支的最新更改
|
|
||||||
REPO_NAME="NianBroken/ZFCheckScores"
|
|
||||||
REPO_URL="https://github.com/$REPO_NAME.git"
|
|
||||||
echo "Repo Url: $REPO_URL"
|
|
||||||
git remote add upstream "$REPO_URL"
|
|
||||||
git fetch upstream main
|
|
||||||
|
|
||||||
- name: Compare main.yml files
|
|
||||||
id: compare_main_yml_files
|
|
||||||
run: |
|
|
||||||
tree -L 3 --dirsfirst
|
|
||||||
# 比对当前分支的main.yml文件与上游分支的main.yml文件是否一致
|
|
||||||
if cmp -s .github/workflows/main.yml <(git show upstream/main:.github/workflows/main.yml); then
|
|
||||||
echo "MAIN_YML_FILES_INCONSISTENT=False" >> $GITHUB_OUTPUT
|
|
||||||
echo "main.yml file is consistent"
|
|
||||||
else
|
|
||||||
echo "MAIN_YML_FILES_INCONSISTENT=True" >> $GITHUB_OUTPUT
|
|
||||||
echo "main.yml file is inconsistent"
|
|
||||||
echo "::error title=main.yml file is inconsistent!" \
|
|
||||||
"::The content of the 'main.yml' file in the current branch" \
|
|
||||||
"does not match the content of the 'main.yml' file in the" \
|
|
||||||
"upstream branch! You need to synchronize the upstream branch" \
|
|
||||||
"manually! If you don't synchronize, there is a chance that" \
|
|
||||||
"your code will have an uncontrollable fatal bug!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Force push changes to main branch
|
|
||||||
run: |
|
|
||||||
# 将更改强制推送到main分支
|
|
||||||
git add .
|
|
||||||
git commit -m "Update branch" || true
|
|
||||||
git push origin main --force
|
|
||||||
|
|
||||||
# 检查成绩
|
# 检查成绩
|
||||||
CheckScores:
|
CheckScores:
|
||||||
name: CheckScores
|
name: CheckScores
|
||||||
|
|
||||||
# SyncFork执行完成后运行
|
|
||||||
needs: SyncFork
|
|
||||||
|
|
||||||
# 在最新版的Ubuntu系统上运行
|
# 在最新版的Ubuntu系统上运行
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
@@ -96,6 +36,12 @@ jobs:
|
|||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@main
|
uses: actions/checkout@main
|
||||||
|
|
||||||
|
- name: Configure Git
|
||||||
|
run: |
|
||||||
|
# 配置Git用户信息
|
||||||
|
git config --global user.email "actions@github.com"
|
||||||
|
git config --global user.name "GitHub Actions"
|
||||||
|
|
||||||
# 配置Python环境
|
# 配置Python环境
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@main
|
uses: actions/setup-python@main
|
||||||
@@ -111,7 +57,6 @@ jobs:
|
|||||||
id: run_main_program
|
id: run_main_program
|
||||||
env:
|
env:
|
||||||
FORCE_PUSH_MESSAGE: ${{ github.event.inputs.force_push_message }}
|
FORCE_PUSH_MESSAGE: ${{ github.event.inputs.force_push_message }}
|
||||||
MAIN_YML_FILES_INCONSISTENT: ${{ needs.SyncFork.outputs.MAIN_YML_FILES_INCONSISTENT }}
|
|
||||||
URL: ${{ secrets.URL }}
|
URL: ${{ secrets.URL }}
|
||||||
USERNAME: ${{ secrets.USERNAME }}
|
USERNAME: ${{ secrets.USERNAME }}
|
||||||
PASSWORD: ${{ secrets.PASSWORD }}
|
PASSWORD: ${{ secrets.PASSWORD }}
|
||||||
@@ -164,7 +109,6 @@ jobs:
|
|||||||
|
|
||||||
# 方便通过截图快速定位到用户
|
# 方便通过截图快速定位到用户
|
||||||
echo "Force Push Message: $FORCE_PUSH_MESSAGE"
|
echo "Force Push Message: $FORCE_PUSH_MESSAGE"
|
||||||
echo "main.yml Files Inconsistent: $MAIN_YML_FILES_INCONSISTENT"
|
|
||||||
echo "Triggered By: $GITHUB_EVENT_NAME"
|
echo "Triggered By: $GITHUB_EVENT_NAME"
|
||||||
echo "Run By: $GITHUB_TRIGGERING_ACTOR"
|
echo "Run By: $GITHUB_TRIGGERING_ACTOR"
|
||||||
echo "Repository Name: $REPOSITORY_NAME"
|
echo "Repository Name: $REPOSITORY_NAME"
|
||||||
|
|||||||
@@ -25,13 +25,10 @@ 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")
|
github_step_summary = os.environ.get("GITHUB_STEP_SUMMARY")
|
||||||
main_yml_files_inconsistent = os.environ.get("MAIN_YML_FILES_INCONSISTENT")
|
|
||||||
|
|
||||||
# 将字符串转换为布尔值
|
# 将字符串转换为布尔值
|
||||||
# 是否强制推送信息
|
# 是否强制推送信息
|
||||||
force_push_message = force_push_message == "True"
|
force_push_message = force_push_message == "True"
|
||||||
# 当前分支的main.yml文件与上游分支的main.yml文件是否不一致
|
|
||||||
main_yml_files_inconsistent = main_yml_files_inconsistent == "True"
|
|
||||||
|
|
||||||
# 定义文件路径
|
# 定义文件路径
|
||||||
info_file_path = "info.txt"
|
info_file_path = "info.txt"
|
||||||
@@ -290,7 +287,6 @@ workflow_info = (
|
|||||||
f"------\n"
|
f"------\n"
|
||||||
f"工作流信息:\n"
|
f"工作流信息:\n"
|
||||||
f"Force Push Message:{force_push_message}\n"
|
f"Force Push Message:{force_push_message}\n"
|
||||||
f"main.yml Files Inconsistent:{main_yml_files_inconsistent}\n"
|
|
||||||
f"Triggered By:{github_event_name}\n"
|
f"Triggered By:{github_event_name}\n"
|
||||||
f"Run By:{github_triggering_actor}\n"
|
f"Run By:{github_triggering_actor}\n"
|
||||||
f"Repository Name:{repository_name}\n"
|
f"Repository Name:{repository_name}\n"
|
||||||
@@ -319,17 +315,6 @@ first_run_text = (
|
|||||||
"------"
|
"------"
|
||||||
)
|
)
|
||||||
|
|
||||||
# 当前分支的main.yml文件与上游分支的main.yml文件不一致时需要使用到的所有信息
|
|
||||||
if main_yml_files_inconsistent:
|
|
||||||
integrated_send_info = (
|
|
||||||
f"警告:你需要手动同步上游分支\n"
|
|
||||||
f"同步方法如下:\n"
|
|
||||||
f"1. 打开你的仓库首页:https://github.com/{repository_name}\n"
|
|
||||||
f"2. 点击 Sync fork\n"
|
|
||||||
f"3. 点击 Update branch 或 Discard xxx commits\n"
|
|
||||||
f"------\n"
|
|
||||||
f"{integrated_send_info}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# 整合首次运行时需要使用到的所有信息
|
# 整合首次运行时需要使用到的所有信息
|
||||||
first_time_run_integrated_send_info = f"{first_run_text}\n" f"{integrated_send_info}"
|
first_time_run_integrated_send_info = f"{first_run_text}\n" f"{integrated_send_info}"
|
||||||
|
|||||||
Reference in New Issue
Block a user