From 11cace0604278d635bfd85d7c55c6b6ce5454bf9 Mon Sep 17 00:00:00 2001 From: "gha-template-repo-token-generator[bot]" <114375963+gha-template-repo-token-generator[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 08:13:26 +0000 Subject: [PATCH] chore: Sync Files - 2023/04/20 -- [bot] synced local '.github/workflows/' with remote 'sync-files/workflows/generic/' --- .github/workflows/codeball.yml | 2 +- .../workflows/delete-disabled-workflows.yml | 55 ++++++++++++++----- .github/workflows/label-sync.yml | 4 +- .github/workflows/lint-pr-actions-skip.yml | 2 +- .github/workflows/lint-pr-actions.yml | 2 +- .github/workflows/pr-labeller.yml | 2 +- .github/workflows/todo.yml | 4 +- 7 files changed, 48 insertions(+), 23 deletions(-) diff --git a/.github/workflows/codeball.yml b/.github/workflows/codeball.yml index fc4eefaa..fbcf4d9c 100644 --- a/.github/workflows/codeball.yml +++ b/.github/workflows/codeball.yml @@ -27,7 +27,7 @@ concurrency: jobs: codeball-review: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest timeout-minutes: 10 if: ${{ !github.event.pull_request.draft }} name: Run Codeball Code Review diff --git a/.github/workflows/delete-disabled-workflows.yml b/.github/workflows/delete-disabled-workflows.yml index 96142891..c301b23b 100644 --- a/.github/workflows/delete-disabled-workflows.yml +++ b/.github/workflows/delete-disabled-workflows.yml @@ -1,4 +1,4 @@ -name: Delete Disabled and Obsolete Workflows +name: Delete Disabled and Deprecated Workflows on: workflow_dispatch: @@ -6,34 +6,38 @@ on: github-token: description: 'Custom GitHub Token, to not be rate limited to 1,000 requests, defaults to GITHUB_TOKEN' required: false - purge-obsoletes: - description: 'Delete obsolete workflows, defaults to true' + purge-deprecated: + description: 'Delete deprecated workflows, defaults to true' required: false default: "true" delete-disabled: description: 'Delete disabled workflows, defaults to true' required: false default: "true" + wait-days: + description: 'Number of days to wait before deleting disabled workflows, defaults to 7' + required: false + default: 7 + type: number schedule: - # run twice a week on Sunday and Thursday at 00:00 - - cron: '0 0 * * 0,4' + - cron: '0 0 * * 4' # At 00:00, only on Thursday permissions: actions: write contents: read jobs: - delete-obsolete-workflows: - runs-on: ubuntu-22.04 + delete-deprecated-workflows: + runs-on: ubuntu-latest timeout-minutes: 15 - if: inputs.purge-obsoletes == true + if: inputs.purge-deprecated == true steps: - - uses: otto-contentfactory/purge-workflow-runs@v1 + - uses: otto-de/purge-deprecated-workflow-runs@v1 with: token: ${{ inputs.github-token || secrets.GITHUB_TOKEN }} delete-disabled-workflows: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest timeout-minutes: 15 if: inputs.delete-disabled == true steps: @@ -46,15 +50,26 @@ jobs: repo: context.repo.repo, } - const disabledWorkflows = await github.paginate( + // filter out workflows that are not disabled + const allDisabledWorkflows = await github.paginate( github.rest.actions.listRepoWorkflows, githubContext ).then(workflows => workflows.filter(workflow => workflow.state == 'disabled_manually')) - console.log('::group::List of disabled workflows') + // filter out workflows that have only been disabled for less than wait-days + const disabledWorkflows = allDisabledWorkflows.filter(workflow => { + const now = new Date() + const disabledAt = new Date(workflow.updated_at) + const diff = now - disabledAt + const days = diff / (1000 * 60 * 60 * 24) + return days > ${{ inputs.wait-days }} + }) + + console.log(`::group::List of disabled workflows older than ${{ inputs.wait-days }}`) console.log(disabledWorkflows) console.log('::endgroup::') + // get the runs for each workflow for (const workflow of disabledWorkflows) { const runs = await github.paginate( github.rest.actions.listWorkflowRuns, @@ -64,18 +79,28 @@ jobs: } ) - console.log(`::group::Workflow #${workflow.id} >> Runs`) - console.log(runs) + console.log(`::group::Workflow ${workflow.id} >> Title`) + console.log(`::group::Workflow ${workflow.id} >> Runs`) + + // log the title of each run + for (const run of runs) { + console.log(`::group::Workflow ${workflow.id} >> Run ${run.id} >> Title`) + console.log(run.head_commit.message) + console.log('::endgroup::') + } console.log('::endgroup::') + // delete each run for (const run of runs) { const response = await github.rest.actions.deleteWorkflowRun({ ...githubContext, run_id: run.id, }) - console.log(`::group::Workflow #${workflow.id} >> Run #${run.id} >> Delete`) + console.log(`::group::Workflow ${workflow.id} >> Run ${run.id} >> Delete`) console.log(response) console.log('::endgroup::') + } + } diff --git a/.github/workflows/label-sync.yml b/.github/workflows/label-sync.yml index 86d94175..49e3710b 100644 --- a/.github/workflows/label-sync.yml +++ b/.github/workflows/label-sync.yml @@ -5,7 +5,7 @@ name: "Sync Available Github Labels" on: workflow_dispatch: schedule: - - cron: "30 4 * * *" + - cron: "30 4 * * 0" push: paths: - .github/config/labels.yml @@ -25,7 +25,7 @@ concurrency: jobs: sync-labels: name: Sync Github Labels - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 diff --git a/.github/workflows/lint-pr-actions-skip.yml b/.github/workflows/lint-pr-actions-skip.yml index 02ff0ea1..54ec9c21 100644 --- a/.github/workflows/lint-pr-actions-skip.yml +++ b/.github/workflows/lint-pr-actions-skip.yml @@ -32,7 +32,7 @@ concurrency: jobs: lint-actions-workflows: name: Lint Actions Workflows - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest timeout-minutes: 5 if: ${{ !github.event.pull_request.draft }} steps: diff --git a/.github/workflows/lint-pr-actions.yml b/.github/workflows/lint-pr-actions.yml index d0b633a6..e25eeb6a 100644 --- a/.github/workflows/lint-pr-actions.yml +++ b/.github/workflows/lint-pr-actions.yml @@ -34,7 +34,7 @@ concurrency: jobs: lint-actions-workflows: name: Lint Actions Workflows - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 diff --git a/.github/workflows/pr-labeller.yml b/.github/workflows/pr-labeller.yml index efa0f6d6..a7e2fc99 100644 --- a/.github/workflows/pr-labeller.yml +++ b/.github/workflows/pr-labeller.yml @@ -29,7 +29,7 @@ permissions: jobs: pr-labeller: name: "Pull Request Labeller" - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest timeout-minutes: 5 if: ${{ !github.event.pull_request.draft }} steps: diff --git a/.github/workflows/todo.yml b/.github/workflows/todo.yml index b39013ab..17c4f3b8 100644 --- a/.github/workflows/todo.yml +++ b/.github/workflows/todo.yml @@ -5,7 +5,7 @@ name: "Check for TODOs and create or update issues" on: workflow_dispatch: schedule: - - cron: "0 15 * * 6,3" # 15:00 UTC on Saturday = 01:00 AEST on Sunday and Thursday + - cron: "0 15 * * 6" permissions: issues: write @@ -19,7 +19,7 @@ concurrency: jobs: todo-issues: - runs-on: "ubuntu-22.04" + runs-on: "ubuntu-latest" timeout-minutes: 15 steps: - uses: "actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab" # v3