2019-12-22 14:05:15 +00:00
|
|
|
import path from 'path';
|
|
|
|
|
2020-01-20 23:06:14 +00:00
|
|
|
class Action {
|
2019-12-22 14:05:15 +00:00
|
|
|
static get supportedPlatforms() {
|
|
|
|
return ['linux'];
|
|
|
|
}
|
|
|
|
|
2019-12-22 17:07:55 +00:00
|
|
|
static get isRunningLocally() {
|
|
|
|
return process.env.RUNNER_WORKSPACE === undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
static get isRunningFromSource() {
|
2020-01-06 23:16:49 +00:00
|
|
|
return path.basename(__dirname) === 'model';
|
2019-12-22 17:07:55 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 14:05:15 +00:00
|
|
|
static get name() {
|
|
|
|
return 'unity-builder';
|
|
|
|
}
|
|
|
|
|
|
|
|
static get rootFolder() {
|
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
|
|
|
}
|
|
|
|
|
2020-01-07 21:26:15 +00:00
|
|
|
static get builderFolder() {
|
|
|
|
return `${Action.rootFolder}/builder`;
|
|
|
|
}
|
|
|
|
|
2019-12-22 14:05:15 +00:00
|
|
|
static get dockerfile() {
|
2020-01-07 21:26:15 +00:00
|
|
|
return `${Action.builderFolder}/Dockerfile`;
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static get workspace() {
|
|
|
|
return process.env.GITHUB_WORKSPACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|