Skip to content

Commit

Permalink
Adds token info
Browse files Browse the repository at this point in the history
  • Loading branch information
francostramana committed Jan 23, 2024
1 parent 9cfe36e commit 68d3e4a
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 8 deletions.
49 changes: 44 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 21 additions & 3 deletions src/libs/github-check.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import { context, getOctokit } from '@actions/github'
import { getInput } from '@actions/core'
import * as core from '@actions/core'

const prEvents = ['pull_request', 'pull_request_review', 'pull_request_review_comment']

export function isPullRequest(): boolean {
return prEvents.includes(context.eventName)
}

export function getSha(): string {
let sha = context.sha
if (isPullRequest()) {
const pull = context.payload.pull_request
if (pull?.head.sha) {
sha = pull?.head.sha
}
}

return sha
}

const NO_INITIALIZATE = -1

Expand All @@ -11,7 +29,7 @@ export class GitHubCheck {
private checkRunId: number

constructor(checkName: string) {
const GITHUB_TOKEN = getInput('github-token') // TODO: move to inputs.ts file?
const GITHUB_TOKEN = core.getInput('github-token') // TODO: move to inputs.ts file?

this.octokit = getOctokit(GITHUB_TOKEN)
this.checkName = checkName
Expand All @@ -24,7 +42,7 @@ export class GitHubCheck {
owner: context.repo.owner,
repo: context.repo.repo,
name: this.checkName,
head_sha: context.sha
head_sha: getSha()
})

this.checkRunId = result.data.id
Expand Down

0 comments on commit 68d3e4a

Please sign in to comment.