-
Notifications
You must be signed in to change notification settings - Fork 22
/
getInputs.ts
40 lines (34 loc) · 1.06 KB
/
getInputs.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
import { getInput } from "@actions/core/lib/core";
import {
PullsCreateReviewRequestParams,
PullsCreateParams
} from "@octokit/plugin-rest-endpoint-methods/dist-types/generated/rest-endpoint-methods-types";
type Inputs = PullsCreateParams &
Required<
Omit<PullsCreateReviewRequestParams, "pull_number" | "team_reviewers">
>;
export function getInputs(): Inputs {
const head = getInput("head", { required: true });
const title = getInput("title", { required: true });
const base = getInput("base") || "master";
const draft = getInput("draft") ? JSON.parse(getInput("draft")) : undefined;
const body = getInput("body") || undefined;
const reviewers = getInput("reviewers");
const githubRepository = process.env.GITHUB_REPOSITORY;
if (!githubRepository) {
throw new Error("GITHUB_REPOSITORY is not set");
}
const [owner, repo] = githubRepository.split("/");
return {
head,
base,
title,
draft,
body,
owner,
repo,
reviewers: reviewers
? reviewers.split(",").map(reviewer => reviewer.trim())
: []
};
}