2022-06-07 22:15:39 -07:00
|
|
|
const core = require('@actions/core')
|
|
|
|
|
|
|
|
|
|
// Load variables from Actions runtime
|
|
|
|
|
function getRequiredVars() {
|
|
|
|
|
return {
|
2022-06-16 14:28:43 -07:00
|
|
|
githubToken: core.getInput('token'),
|
2022-08-02 20:45:01 -05:00
|
|
|
staticSiteGenerator: core.getInput('static_site_generator'),
|
2022-08-05 17:31:59 -05:00
|
|
|
generatorConfigFile: core.getInput('generator_config_file'),
|
2023-01-30 12:29:09 -06:00
|
|
|
enablement: core.getInput('enablement') === 'true'
|
2022-06-07 22:15:39 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-19 11:47:29 -07:00
|
|
|
// Return the context object
|
|
|
|
|
function getContext() {
|
2022-06-07 22:15:39 -07:00
|
|
|
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
|
|
|
|
|
}
|
2022-07-19 11:47:29 -07:00
|
|
|
|
2022-08-05 15:26:05 -05:00
|
|
|
module.exports = { getContext }
|