From fe64d2478d3058be9bc10de8086aa2def4046337 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Wed, 20 Nov 2024 08:28:32 -0800 Subject: [PATCH] Purge more workflow runs (#53199) --- .github/workflows/purge-old-workflow-runs.yml | 2 +- src/workflows/purge-old-workflow-runs.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/purge-old-workflow-runs.yml b/.github/workflows/purge-old-workflow-runs.yml index 86d911c7b5..07561b6e50 100644 --- a/.github/workflows/purge-old-workflow-runs.yml +++ b/.github/workflows/purge-old-workflow-runs.yml @@ -7,7 +7,7 @@ name: Purge old workflow runs on: workflow_dispatch: schedule: - - cron: '20 */2 * * *' # Run every 2 hours at 20 minutes past the hour + - cron: '20 * * * *' # Run every hour at 20 minutes past the hour permissions: contents: write diff --git a/src/workflows/purge-old-workflow-runs.js b/src/workflows/purge-old-workflow-runs.js index 973a96b27b..51cd86d897 100755 --- a/src/workflows/purge-old-workflow-runs.js +++ b/src/workflows/purge-old-workflow-runs.js @@ -18,7 +18,7 @@ * For every run found, it deletes its logs and its run. * * The total number of deletions is limited by the `MAX_DELETIONS` - * environment variable. The default is 100. + * environment variable. The default is 2000. * */ import fs from 'fs' @@ -29,7 +29,7 @@ import { getOctokit } from '@actions/github' main() async function main() { const DRY_RUN = Boolean(JSON.parse(process.env.DRY_RUN || 'false')) - const MAX_DELETIONS = parseInt(JSON.parse(process.env.MAX_DELETIONS || '100')) + const MAX_DELETIONS = parseInt(JSON.parse(process.env.MAX_DELETIONS || '2000')) const MIN_AGE_DAYS = parseInt(process.env.MIN_AGE_DAYS || '90', 10) const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/') @@ -134,11 +134,11 @@ async function deleteWorkflowRuns( owner, repo, workflow, - { dryRun = false, minAgeDays = 100, maxDeletions = 1000 }, + { dryRun = false, minAgeDays = 90, maxDeletions = 2000 }, ) { // https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates const minCreated = new Date(Date.now() - minAgeDays * 24 * 60 * 60 * 1000) - const minCreatedSearch = `<=${minCreated.toISOString().split('T')[0]}` + const minCreatedSearch = `<${minCreated.toISOString().split('T')[0]}` // Delete is 10, but max is 100. But if we're only going to delete, // 30, use 30. And if we're only going to delete 5, use the default // per_page value of 10.