-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.ts
30 lines (24 loc) · 940 Bytes
/
env.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
import { info } from "./util";
/** load env vars from local .env file */
require("dotenv").config();
/** github user or organization name, e.g. "greenelab" */
const githubUser =
/** read from explicitly set env var */
process.env.GITHUB_USER ||
/** or, read from env var set by github actions */
(process.env.GITHUB_REPOSITORY || "").split("/")[0] ||
"";
/** github auth token */
const githubToken = process.env.GITHUB_TOKEN || "";
/** software heritage auth/api token */
const softwareHeritageToken = process.env.SOFTWARE_HERITAGE_TOKEN || "";
/** log key */
const logKey = (name = "", value = "", truncate = true) =>
info(
`${name}: ${truncate && value ? `"...${value.slice(-4)}"` : `"${value}"`}`,
);
/** log keys */
logKey("GITHUB_USER", githubUser, false);
logKey("GITHUB_TOKEN", githubToken);
logKey("SOFTWARE_HERITAGE_TOKEN", softwareHeritageToken);
export { githubUser, githubToken, softwareHeritageToken };