2023-03-04 00:25:40 +00:00
|
|
|
import path from 'node:path';
|
2019-12-22 14:05:15 +00:00
|
|
|
|
2020-01-20 23:06:14 +00:00
|
|
|
class Action {
|
2023-03-04 00:25:40 +00:00
|
|
|
static get supportedPlatforms(): string[] {
|
2022-02-02 09:15:37 +00:00
|
|
|
return ['linux', 'win32', 'darwin'];
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
static get isRunningLocally(): boolean {
|
2019-12-22 17:07:55 +00:00
|
|
|
return process.env.RUNNER_WORKSPACE === undefined;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
static get isRunningFromSource(): boolean {
|
2020-01-06 23:16:49 +00:00
|
|
|
return path.basename(__dirname) === 'model';
|
2019-12-22 17:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
static get canonicalName(): string {
|
|
|
|
|
if (Action.isRunningFromSource) {
|
|
|
|
|
return path.basename(path.dirname(path.join(path.dirname(__filename), '/..')));
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-22 14:05:15 +00:00
|
|
|
return 'unity-builder';
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
static get rootFolder(): string {
|
2019-12-22 17:07:55 +00:00
|
|
|
if (Action.isRunningFromSource) {
|
|
|
|
|
return path.dirname(path.dirname(path.dirname(__filename)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return path.dirname(path.dirname(__filename));
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
static get actionFolder(): string {
|
2021-03-13 23:44:01 +00:00
|
|
|
return `${Action.rootFolder}/dist`;
|
2020-01-07 21:26:15 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-04 00:25:40 +00:00
|
|
|
static get workspace(): string {
|
|
|
|
|
return process.env.GITHUB_WORKSPACE!;
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static checkCompatibility() {
|
|
|
|
|
const currentPlatform = process.platform;
|
|
|
|
|
if (!Action.supportedPlatforms.includes(currentPlatform)) {
|
|
|
|
|
throw new Error(`Currently ${currentPlatform}-platform is not supported`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-20 23:06:14 +00:00
|
|
|
|
|
|
|
|
export default Action;
|