From 8dc2d6eb6a33f306d770b6457ee2f380a80d257a Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Thu, 20 May 2021 16:49:57 -0400 Subject: [PATCH] Update location of typescript definitions (#743) https://github.com/octokit/webhooks.js#typescript --- packages/github/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/github/README.md b/packages/github/README.md index 21daad31..30e6a68e 100644 --- a/packages/github/README.md +++ b/packages/github/README.md @@ -59,18 +59,19 @@ const newIssue = await octokit.rest.issues.create({ ## Webhook payload typescript definitions -The npm module `@octokit/webhooks` provides type definitions for the response payloads. You can cast the payload to these types for better type information. +The npm module `@octokit/webhooks-definitions` provides type definitions for the response payloads. You can cast the payload to these types for better type information. -First, install the npm module `npm install @octokit/webhooks` +First, install the npm module `npm install @octokit/webhooks-definitions` Then, assert the type based on the eventName ```ts import * as core from '@actions/core' import * as github from '@actions/github' -import * as Webhooks from '@octokit/webhooks' +import {PushEvent} from '@octokit/webhooks-definitions/schema' + if (github.context.eventName === 'push') { - const pushPayload = github.context.payload as Webhooks.WebhookPayloadPush - core.info(`The head commit is: ${pushPayload.head}`) + const pushPayload = github.context.payload as PushEvent + core.info(`The head commit is: ${pushPayload.head_commit}`) } ```