Pass input options to GitHub constructor

This commit is contained in:
Jonathan Clem
2019-09-05 11:29:31 -04:00
parent 1aae562f16
commit 0f28aeff3d

11
main.js
View File

@@ -6,10 +6,17 @@ main().catch(handleError)
async function main() {
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor
const script = core.getInput('script', {required: true})
const token = core.getInput('github-token', {required: true})
const debug = core.getInput('debug')
const userAgent = core.getInput('user-agent')
const previews = core.getInput('previews')
const opts = {}
if (debug) opts.log = console
if (userAgent) opts.userAgent = userAgent
if (previews) opts.previews = previews
const client = new GitHub(token, opts)
const script = core.getInput('script', {required: true})
const fn = new AsyncFunction('github', 'context', script)
const client = new GitHub(token)
const result = await fn(client, context)
core.setOutput('result', JSON.stringify(result))
}