Skip to content

Commit

Permalink
version v2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattraks committed Jun 14, 2022
1 parent 21f241a commit c1a2f0d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ The GitHub action to delete workflow runs in a repository. This action (written
The action will calculate the number of days that each workflow run has been retained so far, then use this number to compare with the number you specify for the input parameter "[**`retain_days`**](#3-retain_days)". If the retention days of the workflow run has reached (equal to or greater than) the specified number, the workflow run will be deleted.

## What's new?
* Add the input parameter "[**`delete_workflow_pattern`**](#5-delete_workflow_pattern)". Fill in the specified workflow name, this workflow will be processed, if no workflow is specified, all workflows in the repository will be processed.
* Add the input parameter "[**`delete_workflow_by_state_pattern`**](#6-delete_workflow_by_state_pattern)" and "[**`dry_run`**](#7-dry_run)".
* Add ability to filter workflows by workflow filename (in addition to the name)
* Add ability to filter workflows by state
* Add ability to perform a 'dry run' which logs the changes but doesn't perform the actual deletion.
##

## Inputs
Expand Down Expand Up @@ -37,7 +40,15 @@ The minimum runs to keep for each workflow.

### 5. `delete_workflow_pattern`
#### Required: NO
The name of the workflow. if not set then it will target all workflows.
The name or filename of the workflow. if not set then it will target all workflows.

### 6. `delete_workflow_by_state_pattern`
#### Required: NO
Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually

### 7. `dry_run`
#### Required: NO
Only log actions, do not perform any delete operations.
##

## Examples
Expand Down Expand Up @@ -80,7 +91,13 @@ on:
required: true
default: 6
delete_workflow_pattern:
description: 'The name of the workflow. if not set then it will target all workflows.'
description: 'The name or filename of the workflow. if not set then it will target all workflows.'
required: false
delete_workflow_by_state_pattern:
description: 'Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually'
required: false
dry_run:
description: 'Only log actions, do not perform any delete operations.'
required: false

jobs:
Expand All @@ -95,6 +112,8 @@ jobs:
retain_days: ${{ github.event.inputs.days }}
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }}
dry_run: ${{ github.event.inputs.dry_run }}
```
##
Expand Down
22 changes: 11 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ async function run() {
});

if (delete_workflow_pattern) {
console.log(`💬 workflows containing '${delete_workflow_pattern}' will be targeted`);
workflows = workflows.filter(
({ name, path }) => {
const filename = path.replace(".github/workflows/");
return [name, filename].some(x=> x.indexOf(delete_workflow_pattern) !== -1);
}
);
console.log(`💬 workflows containing '${delete_workflow_pattern}' will be targeted`);
workflows = workflows.filter(
({ name, path }) => {
const filename = path.replace(".github/workflows/");
return [name, filename].some(x => x.indexOf(delete_workflow_pattern) !== -1);
}
);
}

if (delete_workflow_by_state_pattern) {
console.log(`💬 workflows containing state '${delete_workflow_by_state_pattern}' will be targeted`);
workflows = workflows.filter(
({ state }) => state.indexOf(delete_workflow_by_state_pattern) !== -1
);
console.log(`💬 workflows containing state '${delete_workflow_by_state_pattern}' will be targeted`);
workflows = workflows.filter(
({ state }) => state.indexOf(delete_workflow_by_state_pattern) !== -1
);
}

console.log(`💬 found total of ${workflows.length} workflow(s)`);
Expand Down
2 changes: 1 addition & 1 deletion node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "delete-workflow-runs",
"version": "2.0.2",
"version": "2.0.3",
"description": "The GitHub action to delete workflow runs in a repository.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit c1a2f0d

Please sign in to comment.