diff --git a/README.md b/README.md index 6c85b4e..5c41efb 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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: @@ -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 }} ``` ## diff --git a/dist/index.js b/dist/index.js index 4b69000..d0bb998 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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)`); diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index f753a57..333611a 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,6 +1,6 @@ { "name": "delete-workflow-runs", - "version": "2.0.1", + "version": "2.0.3", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package-lock.json b/package-lock.json index 0e0f992..dbaf65c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "delete-workflow-runs", - "version": "2.0.2", + "version": "2.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "delete-workflow-runs", - "version": "2.0.2", + "version": "2.0.3", "license": "ISC", "dependencies": { "@actions/core": "^1.8.2", diff --git a/package.json b/package.json index bd39323..e5d5bdc 100644 --- a/package.json +++ b/package.json @@ -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": {