|
1
|
import { Octokit } from "@octokit/core" |
|
2
|
import * as core from "@actions/core" |
|
3
|
|
|
4
|
const octokit = new Octokit({ |
|
5
|
auth: process.env.GH_TOKEN, |
|
6
|
}) |
|
7
|
|
|
8
|
let prNumber = process.argv.length >= 3 ? process.argv[2] : null |
|
9
|
const threshold = process.argv.length >= 4 ? parseInt(process.argv[3]) : 300 |
|
10
|
|
|
11
|
async function getPrFilesCount() { |
|
12
|
if (!prNumber) { |
|
13
|
throw new Error("Commit SHA is required.") |
|
14
|
} |
|
15
|
|
|
16
|
prNumber = prNumber.replace("/merge", "") |
|
17
|
|
|
18
|
const { data: pr } = await octokit.request( |
|
19
|
"GET /repos/{owner}/{repo}/pulls/{pull_number}", |
|
20
|
{ |
|
21
|
owner: process.env.GIT_OWNER || "medusajs", |
|
22
|
repo: process.env.GIT_REPO || "medusa", |
|
23
|
pull_number: parseInt(prNumber), |
|
24
|
headers: { |
|
25
|
"X-GitHub-Api-Version": "2022-11-28", |
|
26
|
}, |
|
27
|
} |
|
28
|
) |
|
29
|
|
|
30
|
core.setOutput("files_lt_threshold", pr.changed_files < threshold) |
|
31
|
} |
|
32
|
|
|
33
|
void getPrFilesCount() |