forked from iFaxity/wait-on-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
58 lines (51 loc) · 1.33 KB
/
main.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
58
const core = require('@actions/core');
const waitOn = require('wait-on');
function numberInput(name) {
const value = core.getInput(name);
if (value) {
return parseInt(value);
}
}
function booleanInput(name) {
return core.getInput(name).toLowerCase() == 'true';
}
async function main() {
const resource = core.getInput('resource', { required: true }).split(' ');
const config = core.getInput('config');
const delay = numberInput('delay');
const httpTimeout = numberInput('httpTimeout');
const interval = numberInput('interval');
const log = booleanInput('log');
const reverse = booleanInput('reverse');
const simultaneous = numberInput('simultaneous');
const timeout = numberInput('timeout');
const tcpTimeout = numberInput('tcpTimeout');
const verbose = booleanInput('verbose');
const window = numberInput('window');
let defaults = {};
if (config) {
defaults = require(config);
}
const opts = {
...defaults,
resources: Array.isArray(resource) ? resource : [resource],
delay,
httpTimeout,
interval,
log,
reverse,
simultaneous,
timeout,
tcpTimeout,
verbose,
window,
};
try {
// Usage with async await
await waitOn(opts);
core.debug('Successfully waited for resources to become accessible');
} catch(ex) {
core.setFailed(ex);
}
}
main();