-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (23 loc) · 1.03 KB
/
index.js
File metadata and controls
28 lines (23 loc) · 1.03 KB
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
const {debug, setFailed, getInput} = require('@actions/core');
const { isValidJiraState } = require('./validate-jira-state');
const { getJiraKey } = require('./get-jira-key');
async function run() {
try {
// Get all of the inputs defined in the actions.yml file
const pr = getInput('prTitle');
const jiraSecret = getInput('jiraSecret');
const jiraUsername = getInput('jiraUsername');
const statusCategory = getInput('statusCategory'); // Status category has a default so can't be undefined
if(!pr) throw Error('No PR title provided');
if(!jiraSecret) throw Error('No Jira secret provided');
// Extract the Jira key from the PR title
const jiraKey = getJiraKey(pr)
if(!jiraKey) throw Error(`Name of PR is incorrect format. ${pr}`);
// Check the Jira ticket status category
const jiraStateValid = await isValidJiraState(jiraKey, statusCategory, jiraUsername, jiraSecret, debug);
if(!jiraStateValid.result) throw Error(jiraStateValid.message);
} catch (error) {
setFailed(error);
}
}
run();