forked from pulumi/actions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
110 lines (103 loc) · 3.32 KB
/
Copy pathconfig.ts
File metadata and controls
110 lines (103 loc) · 3.32 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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { getInput } from '@actions/core';
import { context } from '@actions/github';
import * as rt from 'runtypes';
import { parseArray, parseBoolean, parseNumber, parseYAML } from './libs/utils';
export const command = rt.Union(
rt.Literal('up'),
rt.Literal('update'),
rt.Literal('refresh'),
rt.Literal('destroy'),
rt.Literal('preview'),
);
export type Commands = rt.Static<typeof command>;
export const options = rt.Partial({
parallel: rt.Number,
message: rt.String,
expectNoChanges: rt.Boolean,
diff: rt.Boolean,
replace: rt.Array(rt.String),
target: rt.Array(rt.String),
policyPacks: rt.Array(rt.String),
policyPackConfigs: rt.Array(rt.String),
targetDependents: rt.Boolean,
editCommentOnPr: rt.Boolean,
userAgent: rt.Literal('pulumi/actions@v3'),
pulumiVersion: rt.String,
});
export const manualPlugin = rt
.Record({
kind: rt.String,
name: rt.String,
})
.And(
rt.Partial({
version: rt.String,
flags: rt.Partial({
checksum: rt.String,
exact: rt.Boolean,
file: rt.String,
reinstall: rt.Boolean,
server: rt.String,
}),
}),
);
export const config = rt
.Record({
// Required options
command: command,
stackName: rt.String,
workDir: rt.String,
commentOnPr: rt.Boolean,
options: options,
// Information inferred from the environment that must be present
isPullRequest: rt.Boolean,
manualPlugins: rt.Array(manualPlugin),
})
.And(
rt.Partial({
// Optional options
cloudUrl: rt.String,
configMap: rt.String,
githubToken: rt.String,
upsert: rt.Boolean,
remove: rt.Boolean,
refresh: rt.Boolean,
secretsProvider: rt.String,
commentOnPrNumber: rt.Number,
}),
);
export type Config = rt.Static<typeof config>;
export type ManualPlugin = rt.Static<typeof manualPlugin>;
export async function makeConfig(): Promise<Config> {
return config.check({
command: getInput('command', { required: true }),
stackName: getInput('stack-name', { required: true }),
workDir: getInput('work-dir') || './',
secretsProvider: getInput('secrets-provider'),
cloudUrl: getInput('cloud-url'),
githubToken: getInput('github-token'),
commentOnPr: parseBoolean(getInput('comment-on-pr')),
commentOnPrNumber: parseNumber(getInput('comment-on-pr-number')),
upsert: parseBoolean(getInput('upsert')),
remove: parseBoolean(getInput('remove')),
refresh: parseBoolean(getInput('refresh')),
configMap: getInput('config-map'),
isPullRequest: context?.payload?.pull_request !== undefined,
options: {
parallel: parseNumber(getInput('parallel')),
message: getInput('message'),
expectNoChanges: parseBoolean(getInput('expect-no-changes')),
diff: parseBoolean(getInput('diff')),
replace: parseArray(getInput('replace')),
target: parseArray(getInput('target')),
targetDependents: parseBoolean(getInput('target-dependents')),
policyPacks: parseArray(getInput('policyPacks')),
policyPackConfigs: parseArray(getInput('policyPackConfigs')),
editCommentOnPr: parseBoolean(getInput('edit-pr-comment')),
userAgent: 'pulumi/actions@v3',
pulumiVersion: getInput('pulumi-version') || "^3",
color: getInput('color'),
},
manualPlugins: parseYAML(getInput('manual-plugins')) || [],
});
}