Skip to content

Commit 5e79c12

Browse files
author
Ahmad Nassri
committed
refactor(api): simplify github api calls
1 parent 3e439a1 commit 5e79c12

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

Diff for: action/lib/api.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
export async function approve (octokit, repo, { number }) {
2-
const { data: { id } } = await octokit.pulls.createReview({
3-
...repo,
4-
pull_number: number
5-
})
6-
7-
await octokit.pulls.submitReview({
1+
export async function approve (octokit, repo, { number }, body) {
2+
await octokit.pulls.createReview({
83
...repo,
94
pull_number: number,
105
event: 'APPROVE',
11-
review_id: id
6+
body
127
})
138
}
149

Diff for: action/lib/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export default async function (inputs) {
2828
const proceed = parse(pull_request.title, inputs.target || 'patch')
2929

3030
if (proceed) {
31-
if (inputs.approve) await approve(octokit, repo, pull_request)
31+
const command = inputs.approve ? approve : comment
3232

33-
await comment(octokit, repo, pull_request, `@dependabot ${inputs.command}`)
33+
await command(octokit, repo, pull_request, `@dependabot ${inputs.command}`)
3434
}
3535
}

0 commit comments

Comments
 (0)