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,
|
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'),
|
|
|
|
|
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}
|