This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
inputs.js
57 lines (54 loc) · 1.57 KB
/
inputs.js
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
import * as core from "@actions/core";
import actions from "./actions/index.js";
import joi from "joi";
const inputsSchema = {
action: joi
.string()
.valid(...Object.keys(actions))
.required(),
approvalAssignmentGroup: joi.string().when("action", {
is: joi.equal("create"),
then: joi.required(),
otherwise: joi.allow(""),
}),
attachmentFilePath: joi.string().when("action", {
is: joi.equal("attach-file"),
then: joi.required(),
otherwise: joi.allow(""),
}),
attachmentFileName: joi.string().allow(""),
attachmentFileContentType: joi
.string()
.allow("")
.empty("")
.default("application/text"),
changeRequestMessage: joi.when("action", {
is: joi.equal("create"),
then: joi.string().required(),
otherwise: joi.string().allow(""),
}),
githubToken: joi.string().required(),
transition: joi.when("action", {
is: joi.equal("transition"),
then: joi
.string()
.pattern(/^(implement|review|closed|\|)+$/)
.required(),
otherwise: joi.allow(""),
}),
requestSysId: joi.string().when("action", {
is: joi.valid("approve", "attach-file", "require-approval", "transition"),
then: joi.required(),
otherwise: joi.allow(""),
}),
serviceNowUrl: joi.string().required(),
serviceNowUsername: joi.string().required(),
serviceNowPassword: joi.string().required(),
};
export const getInputs = () => {
const inputs = {};
Object.keys(inputsSchema).forEach((inputName) => {
inputs[inputName] = core.getInput(inputName);
});
return joi.attempt(inputs, joi.object(inputsSchema));
};