Skip to content

Commit

Permalink
Merge branch 'main' into renovate/patch-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
sammcj committed Aug 23, 2023
2 parents d7ad26d + d0eded8 commit 6ff3141
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 40 additions & 15 deletions .github/workflows/delete-disabled-workflows.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
name: Delete Disabled and Obsolete Workflows
name: Delete Disabled and Deprecated Workflows

on:
workflow_dispatch:
inputs:
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:
Expand All @@ -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,
Expand All @@ -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::')
}
}
4 changes: 2 additions & 2 deletions .github/workflows/label-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-pr-actions-skip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-pr-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -30,8 +30,8 @@ jobs:
REPO: ${{ github.repository }}
SHA: ${{ github.sha }}
REF: ${{ github.ref }}
EXCLUDE_PATTERN: "(node_modules|dist|bin|files|themes)/.*"
EXCLUDE_PATTERN: "(node_modules|dist|bin|files|assets|i18n|themes)/.*"
MIN_WORDS: 2
MIN_CHARACTERS: 10
ADD_LIMIT: 30
ADD_LIMIT: 10
COMMENT_ON_ISSUES: true

0 comments on commit 6ff3141

Please sign in to comment.