Worker: Find package to manage gh webhooks

This commit is contained in:
Arthi-chaud
2022-02-23 13:26:28 +01:00
parent 352cd40cc8
commit e2ca8837bc
4 changed files with 1346 additions and 1 deletions
+1
View File
@@ -21,6 +21,7 @@
"@discordjs/rest": "^0.3.0",
"@googleapis/youtube": "^2.0.0",
"@octokit/rest": "^18.12.0",
"@octokit/webhooks": "^9.22.0",
"discord-api-types": "^0.27.2",
"discord.js": "^13.6.0",
"express": "^4.17.2",
+11
View File
@@ -1,16 +1,22 @@
import { Octokit } from "@octokit/rest";
import { Pipeline, PipelineEnv, PipelineType, ReactionType, ServiceType } from "../models/pipeline";
import { BaseService, reaction, service } from "../models/base-service";
import { Webhooks, createNodeMiddleware } from "@octokit/webhooks";
import { Observable } from "rxjs";
@service(ServiceType.Github)
export class Github extends BaseService {
private _github: Octokit;
private _websocket: Webhooks;
constructor(_: Pipeline) {
super();
///TODO Get various credentials
this._github = new Octokit();
this._websocket = new Webhooks({
secret: "bidibi"
});
}
@reaction(ReactionType.OpenPR, ['owner', 'repo', 'title', 'head', 'base'])
@@ -22,6 +28,11 @@ export class Github extends BaseService {
return {...params, 'url': res.data.url};
}
@action(PipelineType.OnOpenPR, ['owner', 'repo'])
listenOpenPR(params: any): Observable<PipelineEnv> {
this._websocket.on("pull_request.opened", ()
}
@reaction(ReactionType.CommentPR, ['owner', 'repo', 'pull_number', 'body'])
async commentPR(params: any): Promise<PipelineEnv> {
let res = await this._github.pulls.createReviewComment({
File diff suppressed because it is too large Load Diff
+39 -1
View File
@@ -101,7 +101,7 @@
"@octokit/types" "^6.34.0"
deprecation "^2.3.1"
"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0":
"@octokit/request-error@^2.0.2", "@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677"
integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==
@@ -139,6 +139,26 @@
dependencies:
"@octokit/openapi-types" "^11.2.0"
"@octokit/webhooks-methods@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@octokit/webhooks-methods/-/webhooks-methods-2.0.0.tgz#1108b9ea661ca6c81e4a8bfa63a09eb27d5bc2db"
integrity sha512-35cfQ4YWlnZnmZKmIxlGPUPLtbkF8lr/A/1Sk1eC0ddLMwQN06dOuLc+dI3YLQS+T+MoNt3DIQ0NynwgKPilig==
"@octokit/webhooks-types@5.2.0":
version "5.2.0"
resolved "https://registry.yarnpkg.com/@octokit/webhooks-types/-/webhooks-types-5.2.0.tgz#9d1d451f37460107409c81cab04dd473108abb02"
integrity sha512-OZhKy1w8/GF4GWtdiJc+o8sloWAHRueGB78FWFLZnueK7EHV9MzDVr4weJZMflJwMK4uuYLzcnJVnAoy3yB35g==
"@octokit/webhooks@^9.22.0":
version "9.22.0"
resolved "https://registry.yarnpkg.com/@octokit/webhooks/-/webhooks-9.22.0.tgz#07a36a10358d39c1870758fae2b1ad3c24ca578d"
integrity sha512-wUd7nGfDRHG6xkz311djmq6lIB2tQ+r94SNkyv9o0bQhOsrkwH8fQCM7uVsbpkGUU2lqCYsVoa8z/UC9HJgRaw==
dependencies:
"@octokit/request-error" "^2.0.2"
"@octokit/webhooks-methods" "^2.0.0"
"@octokit/webhooks-types" "5.2.0"
aggregate-error "^3.1.0"
"@sapphire/async-queue@^1.1.9":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@sapphire/async-queue/-/async-queue-1.2.0.tgz#7a56afd318101d338433d7180ebd6af349243268"
@@ -262,6 +282,14 @@ agent-base@6:
dependencies:
debug "4"
aggregate-error@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a"
integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==
dependencies:
clean-stack "^2.0.0"
indent-string "^4.0.0"
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
@@ -369,6 +397,11 @@ chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"
clean-stack@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==
colors@^1.1.2:
version "1.4.0"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78"
@@ -764,6 +797,11 @@ iconv-lite@0.4.24:
dependencies:
safer-buffer ">= 2.1.2 < 3"
indent-string@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251"
integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"