refactor: replace axios call with octokit
This commit is contained in:
@@ -63,7 +63,7 @@ export async function run(): Promise<void> {
|
||||
|
||||
if (createPRComments === 'true') {
|
||||
await pr.createComment(
|
||||
token,
|
||||
octokit,
|
||||
github.context.repo.owner,
|
||||
github.context.repo.repo,
|
||||
ctx.event.number,
|
||||
|
||||
17
src/pr.ts
17
src/pr.ts
@@ -1,19 +1,16 @@
|
||||
import axios, {AxiosResponse} from 'axios'
|
||||
import {Octokit} from '@octokit/rest'
|
||||
|
||||
export async function createComment(
|
||||
token: string,
|
||||
octokit: Octokit,
|
||||
owner: string,
|
||||
repo: string,
|
||||
prNumber: number,
|
||||
body: string
|
||||
): Promise<AxiosResponse> {
|
||||
const instance = axios.create({
|
||||
baseURL: 'https://api.github.com',
|
||||
headers: {
|
||||
Authorization: `token ${token}`
|
||||
}
|
||||
})
|
||||
return instance.post(`/repos/${owner}/${repo}/issues/${prNumber}/comments`, {
|
||||
): Promise<void> {
|
||||
octokit.rest.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: prNumber,
|
||||
body
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user