Skip to content

重试更新计分板 #27150

重试更新计分板

重试更新计分板 #27150

Workflow file for this run

# 重试被取消的workflow run
name: 重试更新计分板
on:
workflow_dispatch:
schedule:
# - cron: '*/12 2-16 * * *'
# - cron: '30 0-1,17-23 * * *'
- cron: '30 * * * *'
permissions:
actions: write
jobs:
rerun:
runs-on: ubuntu-latest
steps:
- name: 重试
uses: actions/github-script@v7
with:
script: |
/*async function list_cancelled_workflow_runs() {
let r = (await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "add-score.yml",
per_page: 100,
page: 1
})).data;
r.workflow_runs = r.workflow_runs.filter(run => run.conclusion === "cancelled");
r.total_count = r.workflow_runs.length;
return r;
}*/
for (let i = 0; i < 10; i++) {
if (i !== 0)
await new Promise(resolve => setTimeout(resolve, 30000));
const r = (await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "add-score.yml",
status: "cancelled",
per_page: 100,
page: 1
})).data;
// const r = await list_cancelled_workflow_runs(); // 最近GitHub Actions查询workflow run有问题,所以手动进行处理
console.log(r.total_count);
if (r.total_count === 0)
return;
const count = r.total_count > 100 ? 100 : r.total_count;
const id = r.workflow_runs[count - 1].id;
console.log(id);
console.log(r.workflow_runs[count - 1].run_number);
await github.request("POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun", {
owner: context.repo.owner,
repo: context.repo.repo,
run_id: id
});
}