-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
45 lines (39 loc) · 1.29 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
const core = require('@actions/core')
const { createVersionAndUpdateFixVersions } = require('./utils/jira')
async function run() {
try {
const changelog = core.getInput('changelog')
const jiraVersion = core.getInput('jiraVersion')
const regexp = /^[.A-Za-z0-9_-]*$/
if (!changelog) {
core.setFailed(
'changelog property is required. Generate the changelog with github action onXmaps/jirafy-changelog and reference the step output.'
)
}
if (!jiraVersion) {
core.setFailed('jiraVersion property is required. Try setting the value to ${{ github.event.release.tag_name }}')
}
if (!!jiraVersion && regexp.test(jiraVersion)) {
await syncChangelogToJira(changelog, jiraVersion)
} else {
core.setFailed('Branch names must contain only numbers, strings, underscores, periods, and dashes.')
}
} catch (error) {
core.setFailed(error.message)
}
}
async function syncChangelogToJira(changelog, jiraVersion) {
try {
core.info(`jiraVersion is: ${jiraVersion}`)
core.info(`changelog is: ${changelog}`)
createVersionAndUpdateFixVersions(changelog, jiraVersion)
} catch (err) {
core.setFailed(`Jirafy Sync failed: ${err.message}`)
process.exit(0)
}
}
try {
run()
} catch (error) {
core.setFailed(error.message)
}