From 174f2a27dd77e6631911c644b8d4bf341c6309bd Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Thu, 17 Jun 2021 23:19:10 +0200 Subject: [PATCH] Add `delay` option --- source/app/action/index.mjs | 8 ++++++++ source/plugins/core/metadata.yml | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/source/app/action/index.mjs b/source/app/action/index.mjs index 4d7dd287..17ae09d5 100644 --- a/source/app/action/index.mjs +++ b/source/app/action/index.mjs @@ -92,6 +92,7 @@ async function wait(seconds) { retries, "retries.delay":retries_delay, "output.action":_action, + delay, ...config } = metadata.plugins.core.inputs.action({core}) const q = {...query, ...(_repo ? {repo:_repo} : null), template} @@ -449,6 +450,13 @@ async function wait(seconds) { } } + //Delay + if (delay) { + info.break() + info("Delay before ending job", `${delay}s`) + await new Promise(solve => setTimeout(solve, delay*1000)) + } + //Success info.break() console.log("Success, thanks for using metrics!") diff --git a/source/plugins/core/metadata.yml b/source/plugins/core/metadata.yml index ba0ea90e..08421585 100644 --- a/source/plugins/core/metadata.yml +++ b/source/plugins/core/metadata.yml @@ -284,4 +284,13 @@ inputs: use_prebuilt_image: description: Use pre-built image from GitHub registry type: boolean - default: yes \ No newline at end of file + default: yes + + # Time to wait (in seconds) at the end of job + # Use this to avoid triggering abuse mechanics on large workflows + delay: + description: Use this to avoid triggering abuse mechanics on large workflows + type: number + default: 0 + min: 0 + max: 3600 \ No newline at end of file