From 3a624739d047c7b49719f179fd271804897aa18d Mon Sep 17 00:00:00 2001 From: Webber Date: Mon, 28 Sep 2020 19:16:34 +0200 Subject: [PATCH] Add onlyPrefix and exceptPrefix arguments --- README.md | 20 ++++++++++++++++++++ action.yml | 8 ++++++++ src/utils.ts | 7 ++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3445dd3..a40887a 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,26 @@ jobs: expire-in: 7days # Setting this to 0 will delete all artifacts ``` +### Optional arguments + +#### `onlyPrefix` + +Only purge artifacts that start with `tmp_` as a prefix. + +```yaml +with: + onlyPrefix: tmp_ +``` + +#### `exceptPrefix` + +Exclude any artifacts that start with `prod_` as a prefix + +```yaml +with: + exceptPrefix: prod_ +``` + ## Contributing There are few improvements to be made, namely diff --git a/action.yml b/action.yml index a75e155..66d9202 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,14 @@ inputs: token: required: true description: 'Github auth token' + onlyPrefix: + required: false + description: 'Only artifacts with the specified prefix will be deleted' + default: '' + exceptPrefix: + required: false + description: 'Artifacts with this prefix will not be included for deletion' + default: '' runs: using: 'node12' main: 'dist/index.js' diff --git a/src/utils.ts b/src/utils.ts index dc8f89e..6b2552d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -44,9 +44,14 @@ export async function* eachArtifact( export interface IActionInputs { expireInMs: number + onlyPrefix: string + exceptPrefix: string } export function getActionInputs(): IActionInputs { const expireInHumanReadable = core.getInput('expire-in', { required: true }) const expireInMs = parseDuration(expireInHumanReadable) - return { expireInMs } + const onlyPrefix = core.getInput('onlyPrefix', { required: false }) + const exceptPrefix = core.getInput('exceptPrefix', { required: false }) + + return { expireInMs, onlyPrefix, exceptPrefix } }