From 5a24ba633e3ab70691756ac18d3b7baeed47726f Mon Sep 17 00:00:00 2001 From: kentaro-m Date: Sat, 27 Nov 2021 17:04:34 +0900 Subject: [PATCH] refactor: use @octokit/webhooks-types for the types of payload --- package-lock.json | 13 +++++++++++++ package.json | 1 + src/handler.ts | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index e4134962..b88b68e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "lodash": "^4.17.20" }, "devDependencies": { + "@octokit/webhooks-types": "^4.17.1", "@types/jest": "^27.0.2", "@types/js-yaml": "^3.12.1", "@types/lodash": "^4.14.141", @@ -1294,6 +1295,12 @@ "os-name": "^3.1.0" } }, + "node_modules/@octokit/webhooks-types": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/@octokit/webhooks-types/-/webhooks-types-4.17.1.tgz", + "integrity": "sha512-L8VCfue+t5oopkPr81f2+LgWLAZbaX6gyu5fVYhWq8QE/QmzdyHuQr5zbUbCfAGAC0a1eRPPYmwPFPFOncku7A==", + "dev": true + }, "node_modules/@sinonjs/commons": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", @@ -7426,6 +7433,12 @@ } } }, + "@octokit/webhooks-types": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/@octokit/webhooks-types/-/webhooks-types-4.17.1.tgz", + "integrity": "sha512-L8VCfue+t5oopkPr81f2+LgWLAZbaX6gyu5fVYhWq8QE/QmzdyHuQr5zbUbCfAGAC0a1eRPPYmwPFPFOncku7A==", + "dev": true + }, "@sinonjs/commons": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", diff --git a/package.json b/package.json index 1703ed45..ed3c76d1 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "lodash": "^4.17.20" }, "devDependencies": { + "@octokit/webhooks-types": "^4.17.1", "@types/jest": "^27.0.2", "@types/js-yaml": "^3.12.1", "@types/lodash": "^4.14.141", diff --git a/src/handler.ts b/src/handler.ts index a6ff51f5..4bab1fa6 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -3,6 +3,7 @@ import * as github from '@actions/github' import { Context } from '@actions/github/lib/context' import * as utils from './utils' import { PullRequest } from './pull_request' +import { PullRequestEvent } from '@octokit/webhooks-types' export interface Config { addReviewers: boolean @@ -32,7 +33,8 @@ export async function handlePullRequest( throw new Error('the webhook payload is not exist') } - const { title, draft, user, number } = context.payload.pull_request + const { pull_request: event } = context.payload as PullRequestEvent + const { title, draft, user, number } = event const { skipKeywords, useReviewGroups,