generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.ts
29 lines (25 loc) · 866 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as core from '@actions/core'
import * as github from '@actions/github'
import type {ReleaseReleasedEvent} from '@octokit/webhooks-types'
import {sendReleaseNotification} from './send-release-notification'
async function run(): Promise<void> {
try {
core.debug(`Sending notification...`)
const slackWebhookUrl: string = core.getInput('slack_webhook_url')
const context = github.context
const {eventName, repo} = context
if (eventName !== 'release') {
core.setFailed('Action should only be run on release publish events')
}
const payload = context.payload as ReleaseReleasedEvent
await sendReleaseNotification({
slackWebhookUrl,
release: payload.release,
repo
})
core.debug('Sent notification')
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
}
}
run()