Skip to content

Commit 8cc6a98

Browse files
committed
Update extractEvent function
1 parent 5613505 commit 8cc6a98

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

dist/index.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as core from '@actions/core'
22
import * as github from '@actions/github'
3-
import {Context} from '@actions/github/lib/context'
3+
import {WebhookPayload} from '@actions/github/lib/interfaces'
44
import {DeploymentEnvironment} from './DeploymentEnvironment'
55
import {Environment} from './Environment'
66
import {Octokit} from '@octokit/core'
@@ -21,9 +21,9 @@ const ORGANISATION = 'switcher-ie'
2121

2222
function extractEvent<
2323
EventName extends keyof EventPayloadMap,
24-
Payload extends EventPayloadMap[EventName]
25-
>(context: Context): Payload {
26-
return context.payload as Payload
24+
Event extends EventPayloadMap[EventName]
25+
>(eventName: EventName, payload: WebhookPayload): Event {
26+
return payload as Event
2727
}
2828

2929
async function createDeployment(
@@ -168,16 +168,17 @@ async function triggerDeployment(): Promise<Deployment[]> {
168168
// label which doesn't have an open PR assigned.
169169
// - if PR event: check PR for labels, create staging deployment for each match label.
170170
// - else: fail step
171+
171172
switch (github.context.eventName) {
172173
case 'push':
173174
return await triggerDeploymentsFromPushEvent(
174175
client,
175-
extractEvent(github.context)
176+
extractEvent(github.context.eventName, github.context.payload)
176177
)
177178
case 'pull_request':
178179
return await triggerDeploymentsFromPullRequestEvent(
179180
client,
180-
extractEvent(github.context)
181+
extractEvent(github.context.eventName, github.context.payload)
181182
)
182183
default:
183184
throw new Error(

0 commit comments

Comments
 (0)