Skip to content

Commit 3558695

Browse files
authored
Merge pull request #414 from bcgsc/feat/DEVSU-2171-auto-ticket-toclininfo-on-release
[DEVSU-2171] auto ticket toclininfo on release
2 parents a2fcce9 + 02b3dba commit 3558695

File tree

3 files changed

+113
-31
lines changed

3 files changed

+113
-31
lines changed

.eslintrc.js

+37-31
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
module.exports = {
2-
"extends": [
3-
"airbnb",
4-
"airbnb-typescript",
5-
"airbnb/hooks",
6-
"plugin:@typescript-eslint/recommended"
2+
extends: [
3+
'airbnb',
4+
'airbnb-typescript',
5+
'airbnb/hooks',
6+
'plugin:@typescript-eslint/recommended',
77
],
8-
"env": {
9-
"browser": true,
10-
"es6": true,
11-
"node": true
8+
env: {
9+
browser: true,
10+
es6: true,
11+
node: true,
1212
},
13-
"parser": "@typescript-eslint/parser",
14-
"parserOptions": {
15-
"project": "./tsconfig.json"
13+
parser: '@typescript-eslint/parser',
14+
parserOptions: {
15+
project: './tsconfig.json',
1616
},
17-
"rules": {
18-
"react/function-component-definition": "off",
19-
"import/extensions": "off",
20-
"react/jsx-props-no-spreading": "off",
21-
"react/require-default-props": "off",
22-
"import/prefer-default-export": "warn",
23-
"max-len": "off",
24-
"no-param-reassign": "warn",
25-
"no-underscore-dangle": ["warn", { "allow": ["_env_"] }],
26-
"no-restricted-syntax": [
27-
"error",
28-
"ForInStatement",
29-
"LabeledStatement",
30-
"WithStatement"
17+
rules: {
18+
'react/function-component-definition': 'off',
19+
'import/extensions': 'off',
20+
'react/jsx-props-no-spreading': 'off',
21+
'react/require-default-props': 'off',
22+
'import/prefer-default-export': 'warn',
23+
'max-len': 'off',
24+
'no-param-reassign': 'warn',
25+
'no-underscore-dangle': ['warn', { allow: ['_env_'] }],
26+
'no-restricted-syntax': [
27+
'error',
28+
'ForInStatement',
29+
'LabeledStatement',
30+
'WithStatement',
3131
],
32-
"prefer-destructuring": ["error", { "object": true, "array": true }],
32+
'prefer-destructuring': ['error', { object: true, array: true }],
3333
},
34-
"settings": {
35-
"import/resolver": {
36-
typescript: {}
34+
settings: {
35+
'import/resolver': {
36+
typescript: {},
3737
},
3838
},
39-
}
39+
overrides: [
40+
{
41+
extends: ['plugin:@typescript-eslint/disable-type-checked'],
42+
files: ['./*.js'],
43+
},
44+
],
45+
};
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Create JIRA ticket on release PR creation
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
branches:
7+
- master
8+
9+
jobs:
10+
create_ticket:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 20
21+
22+
- name: Run script
23+
run: node ./create-jira-ticket.js
24+
env:
25+
JIRA_PROJECT_NAME: ${{ vars.JIRA_PROJECT_NAME }}
26+
JIRA_ISSUE_TYPE: ${{ vars.JIRA_ISSUE_TYPE }}
27+
JIRA_BASE_URL: ${{ vars.JIRA_BASE_URL }}
28+
JIRA_PORT: ${{ vars.JIRA_PORT }}
29+
JIRA_API_TOKEN: ${{ secrets.JACLI_JIRA_TOKEN }}
30+
PR_TITLE: ${{ github.event.pull_request.title }}
31+
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)