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