-
Notifications
You must be signed in to change notification settings - Fork 15
55 lines (50 loc) · 1.6 KB
/
issue.yml
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
name: 'Issue sync with Jira'
on:
issues:
types: [opened]
permissions:
issues: write
contents: read
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Create ticket
uses: actions/github-script@v7
with:
script: |
const action = context.payload.action;
if (action !== 'opened') {
return;
}
const title = context.payload.issue.title;
const body = context.payload.issue.body;
const res = await fetch('https://algolia.atlassian.net/rest/api/2/issue', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Basic ${{ secrets.JIRA_TOKEN }}`
},
body: JSON.stringify({
fields: {
description: `Issue created by ${context.actor} at ${context.payload.issue.html_url} \n\n${body}`,
issuetype: {
id: '10001'
},
parent: {
key: 'DI-2737'
},
project: {
id: '10118'
},
summary: `[GH-ISSUE] ${title}`
},
update: {}
})
});
if (!res.ok) {
throw new Error(`Failed to create ticket: ${res.statusText} (${res.status}) - ${await res.text()}`);
}
const data = await res.json();
console.log(`Created ticket: ${data.key}`);