Skip to content

Commit 8654e84

Browse files
committed
feat: add github action to make CLININFO ticket to check IPR client release PR
DEVSU-2171
1 parent c711b85 commit 8654e84

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Create JIRA ticket on release PR creation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
create_ticket:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 20
20+
21+
- name: Run script
22+
run: node ./create-jira-ticket.js
23+
env:
24+
JIRA_PROJECT_NAME: ${{ vars.JIRA_PROJECT }}
25+
JIRA_ISSUE_TYPE: ${{ vars.JIRA_ISSUE_TYPE_TASK }}
26+
JIRA_BASE_URL: ${{ vars.JIRA_BASE_URL }}
27+
JIRA_PORT: ${{ vars.JIRA_PORT }}
28+
JIRA_API_TOKEN: ${{ secrets.JACLI_JIRA_TOKEN }}
29+
PR_TITLE: ${{ github.event.pull_request.title }}
30+
PR_DESCRIPTION: ${{ github.event.pull_request.body }}

create-jira-ticket.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
const https = require('https');
3+
4+
function createJiraTicket() {
5+
const options = {
6+
method: 'POST',
7+
host: process.env.JIRA_BASE_URL,
8+
port: process.env.JIRA_PORT,
9+
path: '/jira/rest/api/2/issue/',
10+
headers: {
11+
Authorization: `Bearer ${process.env.JIRA_API_TOKEN}`,
12+
Accept: 'application/json',
13+
'Content-Type': 'application/json',
14+
},
15+
};
16+
17+
const issueData = JSON.stringify({
18+
fields: {
19+
project: {
20+
key: process.env.JIRA_PROJECT_NAME,
21+
},
22+
summary: process.env.PR_TITLE,
23+
description: process.env.PR_DESCRIPTION,
24+
issuetype: {
25+
name: process.env.JIRA_ISSUE_TYPE,
26+
},
27+
},
28+
});
29+
30+
const req = https.request(options, (res) => {
31+
res.setEncoding('utf8');
32+
res.on('data', (body) => {
33+
console.log('Body:', body);
34+
});
35+
});
36+
37+
req.on('error', (e) => {
38+
console.error('problem with request:', e.message);
39+
});
40+
41+
req.write(issueData);
42+
req.end();
43+
}
44+
45+
createJiraTicket();

0 commit comments

Comments
 (0)