forked from thomaseizinger/create-pull-request
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetInputs.ts
More file actions
34 lines (28 loc) · 1.04 KB
/
getInputs.ts
File metadata and controls
34 lines (28 loc) · 1.04 KB
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
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())
: []
};
}