This repository has been archived by the owner on Aug 19, 2020. It is now read-only.
forked from atlassian/gajira-create
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·55 lines (44 loc) · 1.46 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
51
52
53
54
55
const fs = require('fs')
const YAML = require('yaml')
const core = require('@actions/core')
const cliConfigPath = `${process.env.HOME}/.jira.d/config.yml`
const configPath = `${process.env.HOME}/jira/config.yml`
const Action = require('./action')
const config = YAML.parse(fs.readFileSync(configPath, 'utf8'))
async function exec () {
try {
const result = await new Action({
argv: parseArgs(),
config,
}).execute()
if (result) {
// result.issue is the issue key
console.log(`Created issue: ${result.issue}`)
console.log(`Saving ${result.issue} to ${cliConfigPath}`)
console.log(`Saving ${result.issue} to ${configPath}`)
// Expose created issue's key as an output
core.setOutput("issue", result.issue)
const yamledResult = YAML.stringify(result)
const extendedConfig = Object.assign({}, config, result)
fs.writeFileSync(configPath, YAML.stringify(extendedConfig))
return fs.appendFileSync(cliConfigPath, yamledResult)
}
console.log('Failed to create issue.')
process.exit(78)
} catch (error) {
console.error(error)
process.exit(1)
}
}
function parseArgs () {
return {
project: core.getInput('project'),
issuetype: core.getInput('issuetype'),
issuelink: core.getInput('issuelink'),
summary: core.getInput('summary'),
description: core.getInput('description'),
fixversion: core.getInput('fixversion'),
team: core.getInput('team'),
}
}
exec()