unity-builder/src/model/action.js

49 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-12-22 14:05:15 +00:00
import path from 'path';
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() {
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`);
}
}
}
export default Action;