🗑️

GitHub actionsのworkflow runsクリア

2024/03/28に公開

zxで実装

const owner = "repo-owner";
const repo = "repo-name";
const file_name = "my-workflow.yml";

while (true) {
  await deleteRuns();
  await sleep(1000);
}

async function deleteRuns() {
  const res =
    await $`gh api "repos/${owner}/${repo}/actions/workflows/${file_name}/runs?per_page=100"`;
  const data = JSON.parse(res);
  const runIds = data.workflow_runs.map((run) => run.id);
  for (const runId of runIds) {
    await $`gh api -X DELETE "repos/${owner}/${repo}/actions/runs/${runId}"`;
  }
}

Discussion