-
Notifications
You must be signed in to change notification settings - Fork 22
/
getInputs.ts
62 lines (56 loc) · 1.71 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { getInput } from '@actions/core/lib/core';
import {
IssuesAddAssigneesParams,
IssuesAddLabelsParams,
PullsCreateParams,
PullsCreateReviewRequestParams,
} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/rest-endpoint-methods-types';
type Inputs =
& PullsCreateParams
& Required<
Omit<PullsCreateReviewRequestParams, 'pull_number'>
>
& Required<
Omit<IssuesAddLabelsParams, 'issue_number'>
>
& Required<
Omit<IssuesAddAssigneesParams, 'issue_number'>
>;
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 assignees = getInput('assignees');
const reviewers = getInput('reviewers');
const team_reviewers = getInput('team_reviewers');
const labels = getInput('labels');
const repository = getInput('repository');
const githubRepository = repository || 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,
assignees: assignees
? assignees.split(',').map(assignee => assignee.trim())
: [],
reviewers: reviewers
? reviewers.split(',').map(reviewer => reviewer.trim())
: [],
team_reviewers: team_reviewers
? team_reviewers.split(',').map(reviewer => reviewer.trim())
: [],
labels: labels
? labels.split(',').map(label => label.trim())
: [],
};
}