Add action logic

This commit is contained in:
Webber
2020-01-29 22:22:26 +01:00
committed by Webber Takken
parent d105f8c891
commit d6c937fe37
14 changed files with 346 additions and 0 deletions

35
src/model/input.js Normal file
View File

@@ -0,0 +1,35 @@
import { getInput } from '@actions/core';
import { includes } from 'lodash-es';
class Input {
static get testModes() {
return ['all', 'playmode', 'editmode'];
}
static getFromUser() {
// Input variables specified in workflow using "with" prop.
const unityVersion = getInput('unityVersion') || '2019.2.11f1';
const testMode = getInput('testMode') || 'all';
const rawProjectPath = getInput('testMode') || '.';
const rawArtifactsPath = getInput('testMode') || 'artifacts';
// Validate input
if (!includes(this.testModes, testMode)) {
throw new Error(`Invalid testMode ${testMode}`);
}
// Sanitise input
const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
// Return sanitised input
return {
unityVersion,
projectPath,
testMode,
artifactsPath,
};
}
}
export default Input;