mirror of https://github.com/actions/toolkit
Update location of typescript definitions (#743)
https://github.com/octokit/webhooks.js#typescriptpull/817/head
parent
3bd746139f
commit
8dc2d6eb6a
|
@ -59,18 +59,19 @@ const newIssue = await octokit.rest.issues.create({
|
||||||
|
|
||||||
## Webhook payload typescript definitions
|
## 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
|
Then, assert the type based on the eventName
|
||||||
```ts
|
```ts
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import * as Webhooks from '@octokit/webhooks'
|
import {PushEvent} from '@octokit/webhooks-definitions/schema'
|
||||||
|
|
||||||
if (github.context.eventName === 'push') {
|
if (github.context.eventName === 'push') {
|
||||||
const pushPayload = github.context.payload as Webhooks.WebhookPayloadPush
|
const pushPayload = github.context.payload as PushEvent
|
||||||
core.info(`The head commit is: ${pushPayload.head}`)
|
core.info(`The head commit is: ${pushPayload.head_commit}`)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue