File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : ' Issue sync with Jira'
2
+ on :
3
+ issues :
4
+ types : [opened]
5
+
6
+ permissions :
7
+ issues : write
8
+ contents : read
9
+
10
+ jobs :
11
+ sync :
12
+ runs-on : ubuntu-latest
13
+ steps :
14
+ - name : Create ticket
15
+ uses : actions/github-script@v7
16
+ with :
17
+ script : |
18
+ const action = context.payload.action;
19
+ if (action !== 'opened') {
20
+ return;
21
+ }
22
+ const title = context.payload.issue.title;
23
+ const body = context.payload.issue.body;
24
+
25
+ const res = await fetch('https://algolia.atlassian.net/rest/api/3/issue', {
26
+ method: 'POST',
27
+ headers: {
28
+ 'Accept': 'application/json',
29
+ 'Content-Type': 'application/json',
30
+ 'Authorization': `Basic ${{ secrets.JIRA_TOKEN }}`
31
+ },
32
+ body: JSON.stringify({
33
+ fields: {
34
+ description: {
35
+ content: [
36
+ {
37
+ content: [
38
+ {
39
+ text: `Issue created by ${context.actor} at ${context.payload.issue.html_url} \n\n${body}`,
40
+ type: 'text'
41
+ }
42
+ ],
43
+ type: 'paragraph'
44
+ }
45
+ ],
46
+ type: 'doc',
47
+ version: 1
48
+ },
49
+ issuetype: {
50
+ id: '10001'
51
+ },
52
+ parent: {
53
+ key: 'DI-2737'
54
+ },
55
+ project: {
56
+ id: '10118'
57
+ },
58
+ summary: `[GH-ISSUE] ${title}`
59
+ },
60
+ update: {}
61
+ })
62
+ });
63
+
64
+ if (!res.ok) {
65
+ throw new Error(`Failed to create ticket: ${res.statusText} (${res.status}) - ${await res.text()}`);
66
+ }
67
+
68
+ const data = await res.json();
69
+ console.log(`Created ticket: ${data.key}`);
You can’t perform that action at this time.
0 commit comments