main.ts 1.3 KB
Newer Older
sinat_25235033's avatar
sinat_25235033 已提交
1 2
import * as core from '@actions/core'
import {wait} from './wait'
sinat_25235033's avatar
sinat_25235033 已提交
3 4
import * as github from '@actions/github'
import * as webhook from '@octokit/webhooks'
sinat_25235033's avatar
sinat_25235033 已提交
5 6 7

async function run(): Promise<void> {
  try {
sinat_25235033's avatar
sinat_25235033 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

    console.log(github.context)
    if (github.context.payload.action && !['created', 'opened'].includes(github.context.payload.action)) {
      console.log(`The status of the action is no applicable ${github.context.payload.action}, return`)
      return
    }
    if (github.context.eventName == "issue") {
      const issuePayload = github.context.payload as webhook.EventPayloads.WebhookPayloadIssues;
      console.log(issuePayload)
    } else if (github.context.eventName == "issue_comment") {
      const issueCommentPayload = github.context.payload as webhook.EventPayloads.WebhookPayloadIssueComment;
      console.log(issueCommentPayload)
    } else {
      console.log(github.context.payload)
    }

sinat_25235033's avatar
sinat_25235033 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37
    const ms: string = core.getInput('milliseconds')
    core.debug(`Waiting ${ms} milliseconds ...`) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true

    core.debug(new Date().toTimeString())
    await wait(parseInt(ms, 10))
    core.debug(new Date().toTimeString())

    core.setOutput('time', new Date().toTimeString())
  } catch (error) {
    core.setFailed(error.message)
  }
}

run()