From ad7ab3a1291977eda001fdd893709ba4c78cfedc Mon Sep 17 00:00:00 2001 From: Smitha Borkar <12040799+smithaborkar@users.noreply.github.com> Date: Tue, 7 Jun 2022 22:15:39 -0700 Subject: [PATCH] Create context.js --- src/context.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/context.js diff --git a/src/context.js b/src/context.js new file mode 100644 index 0000000..64a7af9 --- /dev/null +++ b/src/context.js @@ -0,0 +1,19 @@ +const core = require('@actions/core') + +// Load variables from Actions runtime +function getRequiredVars() { + return { + githubToken: core.getInput('token') + } +} + +module.exports = function getContext() { + const requiredVars = getRequiredVars() + for (const variable in requiredVars) { + if (requiredVars[variable] === undefined) { + throw new Error(`${variable} is undefined. Cannot continue.`) + } + } + core.debug('all variables are set') + return requiredVars +}