Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opc 3543 test released hook #37

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@octokit/core": "^3.2.5",
"@slack/events-api": "^2.3.0",
"@slack/web-api": "^5.1.0",
"apisauce": "^2.0.1",
"apollo-link": "^1.2.12",
"apollo-link-http": "^1.5.15",
"body-parser": "^1.19.0",
Expand Down
3 changes: 0 additions & 3 deletions src/config/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import admin from 'firebase-admin';
import dotenv from 'dotenv';
import { Config } from 'firebase';

dotenv.config();

const serviceAccount: Config = {
type: 'service_account',
project_id: process.env.FIRESTORE_PROYECT_ID || 'aaa',
Expand Down
12 changes: 12 additions & 0 deletions src/config/jiraAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { create } from 'apisauce';

const api = create({
baseURL: 'https://widergy.atlassian.net/rest/api/3',
headers: {
Authorization: `Basic ${process.env.JIRA_AUTH_TOKEN}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
});

export default api;
15 changes: 15 additions & 0 deletions src/handlers/jira/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ApiResponse } from 'apisauce';

import api from '../../config/jiraAPI';

export const addMessage = (
content: Array<{ type: string; content: Array<{ text: string; type: string }> }>,
issueId: string
): Promise<ApiResponse<unknown>> =>
api.post(`/issue/${issueId}/comment`, {
body: {
type: 'doc',
version: 1,
content,
},
});
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import 'regenerator-runtime/runtime';
import express from 'express';
import dotenv from 'dotenv';

import UgoStatus from './controllers/slack/ugo_status';
import { initDirectivesJobs } from './utils/directives';
import GetPrs from './controllers/slack/pr_reminder';
import { createProbot, createNodeMiddleware } from 'probot';
import probotApp from './probotApp';

dotenv.config();

const port = parseInt(process.env.PORT || '8080', 10);

const app = express();
Expand Down
6 changes: 6 additions & 0 deletions src/probotApp/handlers/released.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Context } from 'probot';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const released = async (context: Context<any>): Promise<void> => {};

export default released;
11 changes: 7 additions & 4 deletions src/probotApp/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Probot } from 'probot';
import mergeable from './handlers/mergeable';
import released from './handlers/released';

export = (app: Probot): void => {
app.on(
[
'pull_request.opened',
'pull_request.edited',
'pull_request.labeled',
'pull_request.unlabeled',
'pull_request.reopened',
'pull_request.asd',
'pull_request.asd',
'pull_request.asd',
'pull_request.asd',
],
mergeable
);

app.on(['pull_request.labeled'], released);
};
6 changes: 6 additions & 0 deletions src/probotApp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ export const isWIPorHold = (labels: Array<{ name: string }>): boolean =>
console.log(label.name.toLowerCase());
return WIPandHoldNames.includes(label.name.toLowerCase());
});

export const getReleaseVersionFromComment = (comment: string): string | undefined => {
const regex = /([a-z]+@\d+.\d+.\d+)|(\d+.\d+.\d+)/gi;

return comment.match(regex)?.[0];
};
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,14 @@ anymatch@~3.1.1:
normalize-path "^3.0.0"
picomatch "^2.0.4"

apisauce@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/apisauce/-/apisauce-2.0.1.tgz#cf5af56ea6ff5145e6eeb8d4ba471c7e0662b8c4"
integrity sha512-mJBw3pKmtfVoP6oifnf7/iRJQtNkVb6GkYsVOXN2pidootj1mhGBtzYHOX9FVBzAz5QV2GMu8IJtiNIgZ44kHQ==
dependencies:
axios "^0.21.1"
ramda "^0.25.0"

apollo-link-http-common@^0.2.16:
version "0.2.16"
resolved "https://registry.yarnpkg.com/apollo-link-http-common/-/apollo-link-http-common-0.2.16.tgz#756749dafc732792c8ca0923f9a40564b7c59ecc"
Expand Down Expand Up @@ -3854,6 +3862,11 @@ quick-format-unescaped@^4.0.1:
resolved "https://registry.yarnpkg.com/quick-format-unescaped/-/quick-format-unescaped-4.0.1.tgz#437a5ea1a0b61deb7605f8ab6a8fd3858dbeb701"
integrity sha512-RyYpQ6Q5/drsJyOhrWHYMWTedvjTIat+FTwv0K4yoUxzvekw2aRHMQJLlnvt8UantkZg2++bEzD9EdxXqkWf4A==

ramda@^0.25.0:
version "0.25.0"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.25.0.tgz#8fdf68231cffa90bc2f9460390a0cb74a29b29a9"
integrity sha512-GXpfrYVPwx3K7RQ6aYT8KPS8XViSXUVJT1ONhoKPE9VAleW42YE+U+8VEyGWt41EnEQW7gwecYJriTI0pKoecQ==

range-parser@~1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
Expand Down