From 26043c7a526fe43599c835bec2d87a221a112cd1 Mon Sep 17 00:00:00 2001 From: asvataa Date: Wed, 19 Jun 2024 19:33:50 +0700 Subject: [PATCH] add artifact-retention-days input --- action.yml | 4 ++++ index.js | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 8c2b30e5..8fcb679a 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,10 @@ inputs: matrix-key: required: false description: "Matrix key" + artifact-retention-days: + required: false + default: "90" + description: "Artifact retention day" outputs: required: false description: "YAML structured map of outputs" diff --git a/index.js b/index.js index b4672577..b1a60cc4 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const fs = require('fs'); try { const step_name = core.getInput('matrix-step-name'); const matrix_key = core.getInput('matrix-key'); + const artifact_retention_days = core.getInput('artifact-retention-days'); const outputs = core.getInput('outputs'); core.debug("step_name:") @@ -15,6 +16,9 @@ try { core.debug("matrix_key:") core.debug(matrix_key) + core.debug("artifact_retention_days:") + core.debug(artifact_retention_days) + core.debug("outputs:") core.debug(outputs) @@ -34,6 +38,11 @@ try { const matrix_mode = !isEmptyInput(step_name) && !isEmptyInput(matrix_key) + if (!parseInt(artifact_retention_days, 10)) { + core.setFailed("`artifact-retention-days` can not be non integer"); + return + } + if (!isEmptyInput(outputs)) { try { yaml.parse(outputs) @@ -81,7 +90,8 @@ ${error}`; const rootDirectory = '.' // Also possible to use __dirname const options = { - continueOnError: false + continueOnError: false, + retentionDays: parseInt(artifact_retention_days, 10) } artifactClient.uploadArtifact(artifactName, files, rootDirectory, options)