-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.ts
97 lines (86 loc) · 2.54 KB
/
env.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
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
export const versionPrefix = (() => {
const prefix = Object.keys(process.env).find(key => /^(?:INPUT_)?VERSION_PREFIX$/.test(key));
if (!prefix) {
console.log(`Version prefix required.`);
process.exit(1);
} else {
return process.env[prefix]!;
}
})();
export const versionPrerelease = (() => {
const prerelease = Object.keys(process.env).find(key => /^(?:INPUT_)?VERSION_PRERELEASE$/.test(key));
if (prerelease) {
return process.env[prerelease]!;
}
})();
export const gitEmail = (() => {
const email = Object.keys(process.env).find(key => /^(?:INPUT_)?GIT_EMAIL$/.test(key));
if (!email) {
console.log(`Git email required.`);
process.exit(1);
} else {
return process.env[email]!;
}
})();
export const gitUsername = (() => {
const username = Object.keys(process.env).find(key => /^(?:INPUT_)?GIT_USERNAME$/.test(key));
if (!username) {
console.log(`Git username required.`);
process.exit(1);
} else {
return process.env[username]!;
}
})();
export const dockerBuildArgs = () => Object
.keys(process.env)
.reduce((acc, curr) => {
const [, arg ] = /^(?:INPUT_)?DOCKER_BUILD_ARG_(.+)$/.exec(curr) ?? [];
if (arg) {
return {
...acc,
[arg]: process.env[curr],
};
} else {
return acc;
}
}, {});
export const dockerLabels = () => Object
.keys(process.env)
.reduce((acc, curr) => {
const [, arg ] = /^(?:INPUT_)?DOCKER_LABEL_(.+)$/.exec(curr) ?? [];
if (arg) {
return {
...acc,
[arg]: process.env[curr],
};
} else {
return acc;
}
}, {});
export const dockerRegistry = (() => {
const registry = Object.keys(process.env).find(key => /^(?:INPUT_)?DOCKER_REGISTRY$/.test(key));
if (!registry) {
console.log(`Docker registry url required.`);
process.exit(1);
} else {
return process.env[registry]!;
}
})();
export const dockerImagePrefix = (() => {
const imagePrefix = Object.keys(process.env).find(key => /^(?:INPUT_)?DOCKER_IMAGE_PREFIX$/.test(key));
if (imagePrefix) {
return process.env[imagePrefix]!;
}
})();
export const dockerRegistryUsername = (() => {
const registryUsername = Object.keys(process.env).find(key => /^(?:INPUT_)?DOCKER_REGISTRY_USERNAME$/.test(key));
if (registryUsername) {
return process.env[registryUsername]!;
}
})();
export const dockerRegistryPassword = (() => {
const registryPassword = Object.keys(process.env).find(key => /^(?:INPUT_)?DOCKER_REGISTRY_PASSWORD$/.test(key));
if (registryPassword) {
return process.env[registryPassword]!;
}
})();