generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.ts
42 lines (34 loc) · 985 Bytes
/
github.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
30
31
32
33
34
35
36
37
38
39
40
41
42
const axios = require('axios')
const octoAuth = require('@octokit/auth-action')
const Request = require('@octokit/request')
import * as core from '@actions/core'
export class GitHub {
private requestWithAuth: any
constructor() {}
async performAuth() {
const auth = octoAuth.createActionAuth()
const authentication = await auth()
this.requestWithAuth = Request.request.defaults({
request: {
hook: auth.hook
},
mediaType: {
previews: ['machine-man']
}
})
}
async getLabels(): Promise<string[]> {
return new Promise(async (resolve, reject) => {
const { data: issue, error: error } = await this.requestWithAuth(
'GET /repos/{owner}/{repo}/issues/{pull_number}',
{
owner: 'givve',
repo: 'givve',
//pull_number: core.getInput('pull_request')
pull_number: 7485
}
)
resolve(issue.labels.map((label: any) => label.name))
})
}
}