-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
35 lines (32 loc) · 921 Bytes
/
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
const core = require('@actions/core');
const fetch = require('cross-fetch');
const base64 = require('base-64');
try {
const value = core.getInput('value');
const customField = core.getInput('custom-field');
const issueKey = core.getInput('issue-key');
const jiraBaseUrl = core.getInput('jira-base-url');
const jiraUserEmail = core.getInput('jira-user-email');
const jiraApiToken = core.getInput('jira-api-token');
const url = `${jiraBaseUrl}/rest/api/3/issue/${issueKey}`;
const options = {
headers: {
"Content-Type": "application/json",
"Authorization": "Basic " +
base64.encode([jiraUserEmail, jiraApiToken].join(':'))
}
};
fetch(url, {
...options,
method: 'PUT',
body: `{
"fields": {
"${customField}": "${value}"
}
}`
}).then(console.info).catch(err => {
console.error(err);
});
} catch (error) {
core.setFailed(error);
}