From 2d95a746683e53c1ff52b31921c3db4ff9769122 Mon Sep 17 00:00:00 2001 From: NianBroken Date: Fri, 10 May 2024 22:53:28 +0800 Subject: [PATCH] Added the ability to delete run logs --- .github/workflows/delete_old_runs.yml | 32 ++------------------------- delete_old_runs.py | 2 +- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/.github/workflows/delete_old_runs.yml b/.github/workflows/delete_old_runs.yml index e0ad883..c7b1f1f 100644 --- a/.github/workflows/delete_old_runs.yml +++ b/.github/workflows/delete_old_runs.yml @@ -11,13 +11,12 @@ on: workflow_dispatch: # 可以手动执行 jobs: - # 删除运行记录 - DeleteOldRuns_1: + # 检查成绩 + DeleteOldRuns: name: DeleteOldRuns # 在最新版的Ubuntu系统上运行 runs-on: ubuntu-latest - timeout-minutes: 360 steps: # 使用GitHub Actions提供的动作来检出代码库 @@ -83,30 +82,3 @@ jobs: run: | # 删除__pycache__文件夹 rm -rf __pycache__ - - # 删除运行记录 - DeleteOldRuns_2: - name: DeleteOldRuns - needs: DeleteOldRuns_1 - - # 在最新版的Ubuntu系统上运行 - runs-on: ubuntu-latest - timeout-minutes: 360 - - steps: - - name: Run main program - id: run_main_program - env: - GITHUB_TOKEN: ${{ secrets.GHTOKEN }} - REPOSITORY_NAME: ${{ github.repository }} - - run: | - # 运行主程序 - export BEIJING_TIME="$(TZ='Asia/Shanghai' date +'%Y-%m-%d %H:%M:%S:%3N')" - echo "BEIJING_TIME=$BEIJING_TIME" >> $GITHUB_OUTPUT - if [ -n "$GITHUB_TOKEN" ]; then - python delete_old_runs.py - echo "------" - else - exit 1 - fi \ No newline at end of file diff --git a/delete_old_runs.py b/delete_old_runs.py index b8a0f54..2d9144f 100644 --- a/delete_old_runs.py +++ b/delete_old_runs.py @@ -36,7 +36,7 @@ class GitHubActionsManager: f"Failed to delete run with ID {run_id}. Status code: {response.status_code}" ) # 打印错误信息 - def delete_old_runs(self, max_workers=64): + def delete_old_runs(self, max_workers=2): next_page = self.runs_url # 初始化下一页的URL为第一页 while next_page: # 循环直到没有下一页 print(beijing_time) # 打印时间