-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
50 lines (39 loc) · 1.06 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const fs = require('fs')
const YAML = require('yaml')
const core = require('@actions/core')
const configPath = `${process.env.HOME}/jira/config.yml`
const Action = require('./action')
// eslint-disable-next-line import/no-dynamic-require
const githubEvent = require(process.env.GITHUB_EVENT_PATH)
const config = YAML.parse(fs.readFileSync(configPath, 'utf8'))
async function exec () {
try {
const result = await new Action({
githubEvent,
argv: parseArgs(),
config,
}).execute()
if (result) {
const extendedConfig = Object.assign({}, config, result)
fs.writeFileSync(configPath, YAML.stringify(extendedConfig))
return
}
console.log('Failed to execute the JQL.')
process.exit(78)
} catch (error) {
console.error(error)
process.exit(1)
}
}
function parseArgs () {
const jql = core.getInput('jql')
let fields = core.getInput('fields')
if (!jql) {
throw new Error('Error: please specify a valid jql query.')
}
if (fields) {
fields = fields.split(',');
}
return { jql, fields }
}
exec()