-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (21 loc) · 941 Bytes
/
index.js
File metadata and controls
24 lines (21 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const core = require("@actions/core");
const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args));
(async () => {
try {
const timeLimit = core.getInput("time-limit");
const base = core.getInput("base");
const endpoints = core.getInput("endpoints").split(" ");
for (var endpoint of endpoints) {
const time = Date.now();
await fetch(`${base}${endpoint}`).then((data) => data.text());
const timeTaken = Date.now() - time;
if (timeTaken >= timeLimit) {
core.setFailed(`The endpoint ${endpoint} took ${timeTaken}ms to respond when limit was set to ${timeLimit}ms.`);
} else {
core.info(`The endpoint ${endpoint} took ${timeTaken}ms to respond which is within the ${timeLimit}ms limit.`);
}
}
} catch (err) {
core.setFailed(err.message);
}
})();