generated from noel-templates/typescript
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
inputs.ts
123 lines (107 loc) Β· 4.19 KB
/
inputs.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* π³ Docker Manifest GitHub Action: Simple and tiny GitHub action to link Docker manifests easily.
* Copyright (c) 2022-2023 Noelware, LLC. <team@noelware.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import { getBooleanInput, getInput, warning } from '@actions/core';
import { debug } from 'console';
/**
* Represents the action's inputs
*/
export interface Input {
/**
* A list of input Docker images (that were previously built) as the inputs for the merged manifests.
* Optionally, comma-seperate to create multiple final images with the same manifest.
*/
inputs: string[];
/**
* Comma-seperated list of images that will be applied from the {@link Input.inputs inputs}.
*/
images: string[];
/**
* If the action should apply the **--amend** flag to `docker manifest create` (and `docker manifest push` if `push` is true).
* This is useful if the action has created a manifest but had errored when creating (or pushing) a merged manifest.
*/
amend: boolean;
/**
* If the action should push the outputs to the Docker registry listed as.
*/
push: boolean;
}
export const getInputs = (): Input | null => {
let inputs = getInput('inputs', { trimWhitespace: true, required: true })
.split(',')
.map((i) => i.trim());
let outputs = getInput('images', { trimWhitespace: true, required: true })
.split(',')
.map((i) => i.trim());
const push = getBooleanInput('push', { trimWhitespace: true });
const amend = getBooleanInput('amend', { trimWhitespace: true });
const baseImages = getInput('base-image', { trimWhitespace: true })
.split(',')
.map((i) => i.trim());
if (inputs.length === 0 && baseImages.length > 0) {
warning('Using the `base-image` input has been deprecated since v0.3, please use the `inputs` input instead.');
inputs = baseImages;
}
const extraImages = getInput('extra-images', { trimWhitespace: true })
.split(',')
.map((i) => i.trim());
if (outputs.length === 0 && extraImages.length > 0) {
warning('Using the `extra-images` input has been deprecated since v0.3, please use the `outputs` input instead.');
outputs = extraImages;
}
// Warn if we don't have any inputs
if (inputs.length === 0) {
warning('You will need to set some inputs! Did you forget to use `,` as the seperator?');
debug(
[
'+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+',
`Outputs => ${outputs.join(', ') || 'None'}`,
`Amend => ${amend ? 'Yes' : 'No'}`,
`Push => ${push ? 'Yes' : 'No'}`,
'+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+'
].join('\n')
);
process.exitCode = 1;
return null;
}
// Warn if we don't have any outputs
if (outputs.length === 0) {
warning('You will need to set some outputs! Did you forget to use `,` as the seperator?');
debug(
[
'+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+',
`Inputs => ${inputs.join(', ')}`,
`Amend => ${amend ? 'Yes' : 'No'}`,
`Push => ${push ? 'Yes' : 'No'}`,
'+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+'
].join('\n')
);
process.exitCode = 1;
return null;
}
return {
inputs,
images: outputs,
push,
amend
};
};