Skip to content

Instantly share code, notes, and snippets.

@romanlab
Last active March 15, 2019 05:44
Show Gist options
  • Save romanlab/162435796e72983021bc4cb78bd58a77 to your computer and use it in GitHub Desktop.
Save romanlab/162435796e72983021bc4cb78bd58a77 to your computer and use it in GitHub Desktop.
basic node js script for github actions
const program = require('commander')
const fs = require('fs')
async function doSomething(arg) { return arg }
async function main() {
const event = JSON.parse(fs.readFileSync('/github/workflow/event.json', 'utf8'))
const firstArg = program.firstArg
const result = await doSometing(firstArg)
return result
}
if (require.main === module) {
program
.option('-f, --firstArg <argParam>', 'The list of valid licenses')
.parse(process.argv)
main()
.then(res => {
console.log({ res })
process.exitCode = 0
})
.catch(err => {
console.log({ err })
process.exitCode = 1
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment