From 23dac2175205045fd6904f9e2a2d484de43239a9 Mon Sep 17 00:00:00 2001 From: Dylan Yurgionas Date: Mon, 9 Feb 2026 09:10:41 -0600 Subject: [PATCH] chore: Delete .github/workflows/cleanup.yml Signed-off-by: Dylan Yurgionas --- .github/workflows/cleanup.yml | 102 ---------------------------------- 1 file changed, 102 deletions(-) delete mode 100644 .github/workflows/cleanup.yml diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml deleted file mode 100644 index 4c9eb933..00000000 --- a/.github/workflows/cleanup.yml +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright 2024 The Authors (see AUTHORS file) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: 'cleanup' - -on: - schedule: - - cron: '0 12 * * *' - workflow_dispatch: - -jobs: - remove-old-workflows: - runs-on: 'ubuntu-latest' - permissions: - contents: 'read' - id-token: 'write' - - steps: - - id: 'minty-auth' - uses: 'google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f' # ratchet:google-github-actions/auth@v2 - with: - create_credentials_file: false - export_environment_variables: false - workload_identity_provider: '${{ vars.TOKEN_MINTER_WIF_PROVIDER }}' - service_account: '${{ vars.TOKEN_MINTER_WIF_SERVICE_ACCOUNT }}' - token_format: 'id_token' - id_token_audience: '${{ vars.TOKEN_MINTER_SERVICE_AUDIENCE }}' - id_token_include_email: true - - - id: 'mint-token' - uses: 'abcxyz/github-token-minter/.github/actions/minty@main' # ratchet:exclude - with: - id_token: '${{ steps.minty-auth.outputs.id_token }}' - service_url: '${{ vars.TOKEN_MINTER_SERVICE_URL }}' - requested_permissions: |- - { - "scope": "pkg-cleanup", - "repositories": [], - "permissions": { - "actions": "write", - "workflows": "write" - } - } - - - name: 'Remove old workflows' - uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' # ratchet:actions/github-script@v7 - with: - github-token: '${{ steps.mint-token.outputs.token }}' - script: |- - const today = new Date(); - const cutoff = new Date(new Date().setDate(today.getDate() - 30)); - const cutoffString = cutoff.toISOString().split('T')[0]; - - const repos = await github.paginate(github.rest.repos.listForOrg, { - org: context.repo.owner, - per_page: 100, - }); - - let workflowRuns = []; - for(const repo of repos) { - const runs = await github.paginate(github.rest.actions.listWorkflowRunsForRepo, { - owner: context.repo.owner, - repo: repo.name, - created: `< ${cutoffString}`, - exclude_pull_requests: true, - per_page: 100, - }); - - for (const run of runs) { - if(['action_required', 'in_progress', 'queued', 'requested', 'waiting', 'pending'].includes(run.status)) { - continue; - } - - workflowRuns.push({ - repo_name: repo.name, - run_id: run.id, - }); - } - } - - core.info(`Found ${workflowRuns.length} runs to delete...`) - - for(const run of workflowRuns) { - core.info(`Deleting ${run.repo_name}/${run.run_id}`); - - await github.rest.actions.deleteWorkflowRun({ - owner: context.repo.owner, - repo: run.repo_name, - run_id: run.run_id, - }) - }