Skip to content

Commit 00fd2f1

Browse files
algolia-botmillotp
andcommitted
chore(ci): automaticaly create jira issues on gh issue (generated)
algolia/api-clients-automation#3564 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 94073cf commit 00fd2f1

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/issue.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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}`);

0 commit comments

Comments
 (0)