1 | "use strict";
|
2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3 | if (k2 === undefined) k2 = k;
|
4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5 | }) : (function(o, m, k, k2) {
|
6 | if (k2 === undefined) k2 = k;
|
7 | o[k2] = m[k];
|
8 | }));
|
9 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11 | }) : function(o, v) {
|
12 | o["default"] = v;
|
13 | });
|
14 | var __importStar = (this && this.__importStar) || function (mod) {
|
15 | if (mod && mod.__esModule) return mod;
|
16 | var result = {};
|
17 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18 | __setModuleDefault(result, mod);
|
19 | return result;
|
20 | };
|
21 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
22 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
23 | return new (P || (P = Promise))(function (resolve, reject) {
|
24 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
25 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
26 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
27 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
28 | });
|
29 | };
|
30 | Object.defineProperty(exports, "__esModule", { value: true });
|
31 | exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
32 | const command_1 = require("./command");
|
33 | const file_command_1 = require("./file-command");
|
34 | const utils_1 = require("./utils");
|
35 | const os = __importStar(require("os"));
|
36 | const path = __importStar(require("path"));
|
37 | const oidc_utils_1 = require("./oidc-utils");
|
38 |
|
39 |
|
40 |
|
41 | var ExitCode;
|
42 | (function (ExitCode) {
|
43 | |
44 |
|
45 |
|
46 | ExitCode[ExitCode["Success"] = 0] = "Success";
|
47 | |
48 |
|
49 |
|
50 | ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
51 | })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | function exportVariable(name, val) {
|
62 | const convertedVal = utils_1.toCommandValue(val);
|
63 | process.env[name] = convertedVal;
|
64 | const filePath = process.env['GITHUB_ENV'] || '';
|
65 | if (filePath) {
|
66 | const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
67 | const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
68 | file_command_1.issueCommand('ENV', commandValue);
|
69 | }
|
70 | else {
|
71 | command_1.issueCommand('set-env', { name }, convertedVal);
|
72 | }
|
73 | }
|
74 | exports.exportVariable = exportVariable;
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | function setSecret(secret) {
|
80 | command_1.issueCommand('add-mask', {}, secret);
|
81 | }
|
82 | exports.setSecret = setSecret;
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | function addPath(inputPath) {
|
88 | const filePath = process.env['GITHUB_PATH'] || '';
|
89 | if (filePath) {
|
90 | file_command_1.issueCommand('PATH', inputPath);
|
91 | }
|
92 | else {
|
93 | command_1.issueCommand('add-path', {}, inputPath);
|
94 | }
|
95 | process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
96 | }
|
97 | exports.addPath = addPath;
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | function getInput(name, options) {
|
108 | const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
109 | if (options && options.required && !val) {
|
110 | throw new Error(`Input required and not supplied: ${name}`);
|
111 | }
|
112 | if (options && options.trimWhitespace === false) {
|
113 | return val;
|
114 | }
|
115 | return val.trim();
|
116 | }
|
117 | exports.getInput = getInput;
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 | function getMultilineInput(name, options) {
|
127 | const inputs = getInput(name, options)
|
128 | .split('\n')
|
129 | .filter(x => x !== '');
|
130 | return inputs;
|
131 | }
|
132 | exports.getMultilineInput = getMultilineInput;
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 | function getBooleanInput(name, options) {
|
144 | const trueValue = ['true', 'True', 'TRUE'];
|
145 | const falseValue = ['false', 'False', 'FALSE'];
|
146 | const val = getInput(name, options);
|
147 | if (trueValue.includes(val))
|
148 | return true;
|
149 | if (falseValue.includes(val))
|
150 | return false;
|
151 | throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
|
152 | `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
153 | }
|
154 | exports.getBooleanInput = getBooleanInput;
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | function setOutput(name, value) {
|
163 | process.stdout.write(os.EOL);
|
164 | command_1.issueCommand('set-output', { name }, value);
|
165 | }
|
166 | exports.setOutput = setOutput;
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 | function setCommandEcho(enabled) {
|
173 | command_1.issue('echo', enabled ? 'on' : 'off');
|
174 | }
|
175 | exports.setCommandEcho = setCommandEcho;
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | function setFailed(message) {
|
185 | process.exitCode = ExitCode.Failure;
|
186 | error(message);
|
187 | }
|
188 | exports.setFailed = setFailed;
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 | function isDebug() {
|
196 | return process.env['RUNNER_DEBUG'] === '1';
|
197 | }
|
198 | exports.isDebug = isDebug;
|
199 |
|
200 |
|
201 |
|
202 |
|
203 | function debug(message) {
|
204 | command_1.issueCommand('debug', {}, message);
|
205 | }
|
206 | exports.debug = debug;
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 | function error(message, properties = {}) {
|
213 | command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
214 | }
|
215 | exports.error = error;
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 | function warning(message, properties = {}) {
|
222 | command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
223 | }
|
224 | exports.warning = warning;
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 | function notice(message, properties = {}) {
|
231 | command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
232 | }
|
233 | exports.notice = notice;
|
234 |
|
235 |
|
236 |
|
237 |
|
238 | function info(message) {
|
239 | process.stdout.write(message + os.EOL);
|
240 | }
|
241 | exports.info = info;
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 | function startGroup(name) {
|
250 | command_1.issue('group', name);
|
251 | }
|
252 | exports.startGroup = startGroup;
|
253 |
|
254 |
|
255 |
|
256 | function endGroup() {
|
257 | command_1.issue('endgroup');
|
258 | }
|
259 | exports.endGroup = endGroup;
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 | function group(name, fn) {
|
269 | return __awaiter(this, void 0, void 0, function* () {
|
270 | startGroup(name);
|
271 | let result;
|
272 | try {
|
273 | result = yield fn();
|
274 | }
|
275 | finally {
|
276 | endGroup();
|
277 | }
|
278 | return result;
|
279 | });
|
280 | }
|
281 | exports.group = group;
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 | function saveState(name, value) {
|
293 | command_1.issueCommand('save-state', { name }, value);
|
294 | }
|
295 | exports.saveState = saveState;
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 | function getState(name) {
|
303 | return process.env[`STATE_${name}`] || '';
|
304 | }
|
305 | exports.getState = getState;
|
306 | function getIDToken(aud) {
|
307 | return __awaiter(this, void 0, void 0, function* () {
|
308 | return yield oidc_utils_1.OidcClient.getIDToken(aud);
|
309 | });
|
310 | }
|
311 | exports.getIDToken = getIDToken;
|
312 |
|
\ | No newline at end of file |