mirror of
https://github.com/actions/github-script.git
synced 2025-12-08 16:16:21 +00:00
Initial pass on script Action
This commit is contained in:
20
main.js
Normal file
20
main.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const core = require('@actions/core')
|
||||
const {GitHub, context} = require('@actions/github')
|
||||
|
||||
process.on('unhandledRejection', handleError)
|
||||
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 fn = new AsyncFunction('github', 'context', script)
|
||||
const client = new GitHub(token)
|
||||
const result = await fn(client, context)
|
||||
core.setOutput('result', JSON.stringify(result))
|
||||
}
|
||||
|
||||
function handleError(err) {
|
||||
console.error(err)
|
||||
core.setFailed(err.message)
|
||||
}
|
||||
Reference in New Issue
Block a user