generated from pabio/github-actions-starter
-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathindex.ts
63 lines (56 loc) · 1.9 KB
/
index.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
import { debug, getInput, setFailed } from "@actions/core";
import { updateDependencies } from "./dependencies";
import { generateGraphs } from "./graphs";
import { getSecret } from "./helpers/secrets";
import { getUptimeMonitorVersion } from "./helpers/workflows";
import { generateSite } from "./site";
import { generateSummary } from "./summary";
import { update } from "./update";
import { updateTemplate } from "./update-template";
const token = getSecret("GH_PAT") || getInput("token") || getSecret("GITHUB_TOKEN");
const SECRETS_CONTEXT = process.env.SECRETS_CONTEXT || "{}";
const allSecrets: Record<string, string> = JSON.parse(SECRETS_CONTEXT);
Object.keys(allSecrets).forEach((key) => {
process.env[key] = allSecrets[key];
});
export const run = async () => {
if (!token) throw new Error("GitHub token not found");
console.log(`
🔼 Upptime @${await getUptimeMonitorVersion()}
GitHub-powered open-source uptime monitor and status page by Anand Chowdhary
* Source: https://github.com/upptime/upptime
* Docs and more: https://upptime.js.org
* More by Anand Chowdhary: https://anandchowdhary.com
`);
switch (getInput("command")) {
case "summary":
debug("Starting summary");
case "readme":
debug("Starting readme");
return generateSummary();
case "site":
debug("Starting site");
return generateSite();
case "graphs":
debug("Starting site");
return generateGraphs();
case "response-time":
debug("Starting response-time");
return update(true);
case "update-dependencies":
debug("Starting update-dependencies");
return updateDependencies();
case "update-template":
debug("Starting update-template");
return updateTemplate();
default:
debug("Starting update");
return update();
}
};
run()
.then(() => {})
.catch((error) => {
console.error("ERROR", error);
setFailed(error.message);
});