forked from szenius/set-timezone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (31 loc) · 999 Bytes
/
index.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
const core = require("@actions/core");
const execa = require("execa");
const execCommand = async (file, args) => {
await execa(file, args).stdout.pipe(process.stdout);
};
const setTimezone = async () => {
try {
const platform = process.platform;
switch (platform) {
case "linux":
const timezone = core.getInput("timezoneLinux");
await execCommand("sudo", ["timedatectl", "set-timezone", timezone]);
break;
case "darwin":
const timezone = core.getInput("timezoneMacos");
await execCommand("sudo", ["systemsetup", "-settimezone", timezone]);
break;
case "win32":
const timezone = core.getInput("timezoneWindows");
await execCommand("tzutil", ["/s", timezone]);
break;
default:
core.setFailed(
`Platform ${platform} not supported; Only linux, darwin or win32 are supported now`
);
}
} catch (error) {
core.setFailed(error.message);
}
};
setTimezone();