Files
configure-pages/src/context.js

26 lines
691 B
JavaScript
Raw Normal View History

2022-06-07 22:15:39 -07:00
const core = require('@actions/core')
// Load variables from Actions runtime
function getRequiredVars() {
return {
2022-06-07 22:18:54 -07:00
repositoryNwo: process.env.GITHUB_REPOSITORY,
githubToken: core.getInput('token'),
staticSiteGenerator: core.getInput('static_site_generator'),
enablement: core.getInput('enablement') !== 'false'
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
module.exports = {getContext}