2021-12-29 15:15:39 +00:00
|
|
|
import { GitRepoReader } from './input-readers/git-repo';
|
|
|
|
|
import { GithubCliReader } from './input-readers/github-cli';
|
2020-01-20 23:06:14 +00:00
|
|
|
import Platform from './platform';
|
|
|
|
|
|
2019-12-22 14:05:15 +00:00
|
|
|
const core = require('@actions/core');
|
|
|
|
|
|
2020-05-21 15:44:56 +00:00
|
|
|
/**
|
|
|
|
|
* Input variables specified in workflows using "with" prop.
|
|
|
|
|
*
|
|
|
|
|
* Note that input is always passed as a string, even booleans.
|
|
|
|
|
*/
|
2020-01-20 23:06:14 +00:00
|
|
|
class Input {
|
2021-12-06 20:56:40 +00:00
|
|
|
public static githubEnabled = true;
|
|
|
|
|
public static cliOptions;
|
2021-12-25 20:05:17 +00:00
|
|
|
static get cloudRunnerTests(): boolean {
|
|
|
|
|
return Input.getInput(`CloudRunnerTests`) || false;
|
2021-12-20 19:15:27 +00:00
|
|
|
}
|
2021-12-06 20:56:40 +00:00
|
|
|
private static getInput(query) {
|
|
|
|
|
return Input.githubEnabled
|
|
|
|
|
? core.getInput(query)
|
2021-12-22 01:12:36 +00:00
|
|
|
: Input.cliOptions !== undefined && Input.cliOptions[query] !== undefined
|
2021-12-06 20:56:40 +00:00
|
|
|
? Input.cliOptions[query]
|
|
|
|
|
: process.env[query] !== undefined
|
|
|
|
|
? process.env[query]
|
2021-12-29 16:02:41 +00:00
|
|
|
: process.env[
|
|
|
|
|
query
|
|
|
|
|
.replace(/([A-Z])/g, ' $1')
|
|
|
|
|
.trim()
|
|
|
|
|
.toUpperCase()
|
2021-12-29 16:51:04 +00:00
|
|
|
.replace(/ /g, '_')
|
2021-12-29 16:02:41 +00:00
|
|
|
] !== undefined
|
|
|
|
|
? process.env[
|
|
|
|
|
query
|
|
|
|
|
.replace(/([A-Z])/g, ' $1')
|
|
|
|
|
.trim()
|
|
|
|
|
.toUpperCase()
|
2021-12-29 16:51:04 +00:00
|
|
|
.replace(/ /g, '_')
|
2021-12-29 16:02:41 +00:00
|
|
|
]
|
2021-12-06 20:56:40 +00:00
|
|
|
: false;
|
|
|
|
|
}
|
2021-12-19 22:28:07 +00:00
|
|
|
static get region(): string {
|
2021-12-19 22:35:28 +00:00
|
|
|
return Input.getInput('region') || 'eu-west-2';
|
2021-12-19 22:28:07 +00:00
|
|
|
}
|
|
|
|
|
static get githubRepo(): string {
|
2021-12-29 15:15:39 +00:00
|
|
|
return Input.getInput('GITHUB_REPOSITORY') || GitRepoReader.GetRemote() || 'game-ci/unity-builder';
|
2021-12-19 22:28:07 +00:00
|
|
|
}
|
2021-12-29 18:15:23 +00:00
|
|
|
static async branch() {
|
2021-12-19 01:45:55 +00:00
|
|
|
if (Input.getInput(`REMOTE_BUILDER_CACHE`)) {
|
|
|
|
|
return Input.getInput(`REMOTE_BUILDER_CACHE`);
|
|
|
|
|
} else if (Input.getInput(`GITHUB_REF`)) {
|
|
|
|
|
return Input.getInput(`GITHUB_REF`)
|
|
|
|
|
.split('/')
|
2021-12-29 14:30:26 +00:00
|
|
|
.map((x) => {
|
2021-12-19 01:45:55 +00:00
|
|
|
x = x[0].toUpperCase() + x.slice(1);
|
|
|
|
|
return x;
|
|
|
|
|
})
|
|
|
|
|
.join('');
|
|
|
|
|
} else if (Input.getInput('branch')) {
|
|
|
|
|
return Input.getInput('branch');
|
2021-12-29 18:15:23 +00:00
|
|
|
} else if (await GitRepoReader.GetBranch()) {
|
|
|
|
|
return await GitRepoReader.GetBranch();
|
2021-12-19 01:45:55 +00:00
|
|
|
} else {
|
2021-12-19 22:35:28 +00:00
|
|
|
return 'remote-builder/unified-providers';
|
2021-12-19 01:45:55 +00:00
|
|
|
}
|
2021-12-29 15:15:39 +00:00
|
|
|
//
|
2021-12-19 01:45:55 +00:00
|
|
|
}
|
2021-12-25 19:17:05 +00:00
|
|
|
|
|
|
|
|
static get gitSha() {
|
|
|
|
|
if (Input.getInput(`GITHUB_SHA`)) {
|
|
|
|
|
return Input.getInput(`GITHUB_SHA`);
|
2021-12-29 15:15:39 +00:00
|
|
|
} else if (Input.getInput(`GitSHA`)) {
|
2021-12-25 19:17:05 +00:00
|
|
|
return Input.getInput(`GitSHA`);
|
2021-12-29 15:15:39 +00:00
|
|
|
} else if (GitRepoReader.GetSha()) {
|
|
|
|
|
return GitRepoReader.GetSha();
|
2021-12-25 19:17:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-06 20:56:40 +00:00
|
|
|
static get runNumber() {
|
|
|
|
|
return Input.getInput('GITHUB_RUN_NUMBER') || '0';
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-21 15:44:56 +00:00
|
|
|
static get unityVersion() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('unityVersion') || 'auto';
|
2020-05-21 15:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-18 16:41:31 +00:00
|
|
|
static get customImage() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('customImage');
|
2020-09-18 16:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
2020-05-21 15:44:56 +00:00
|
|
|
static get targetPlatform() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('targetPlatform') || Platform.default;
|
2020-05-21 15:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get projectPath() {
|
2021-12-06 20:56:40 +00:00
|
|
|
const rawProjectPath = Input.getInput('projectPath') || '.';
|
2020-05-21 15:44:56 +00:00
|
|
|
return rawProjectPath.replace(/\/$/, '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get buildName() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('buildName') || this.targetPlatform;
|
2020-05-21 15:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get buildsPath() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('buildsPath') || 'build';
|
2020-05-21 15:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get buildMethod() {
|
2021-12-19 01:45:55 +00:00
|
|
|
return Input.getInput('buildMethod') || ''; // processed in docker file
|
2020-05-21 15:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get versioningStrategy() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('versioning') || 'Semantic';
|
2020-05-21 15:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get specifiedVersion() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('version') || '';
|
2020-05-21 15:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-24 22:02:05 +00:00
|
|
|
static get androidVersionCode() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('androidVersionCode');
|
2020-06-24 22:02:05 +00:00
|
|
|
}
|
|
|
|
|
|
2020-07-06 01:41:21 +00:00
|
|
|
static get androidAppBundle() {
|
2021-12-06 20:56:40 +00:00
|
|
|
const input = Input.getInput('androidAppBundle') || false;
|
2020-07-06 01:41:21 +00:00
|
|
|
|
2020-08-10 14:30:06 +00:00
|
|
|
return input === 'true';
|
2020-07-06 01:41:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get androidKeystoreName() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('androidKeystoreName') || '';
|
2020-07-06 01:41:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get androidKeystoreBase64() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('androidKeystoreBase64') || '';
|
2020-07-06 01:41:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get androidKeystorePass() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('androidKeystorePass') || '';
|
2020-07-06 01:41:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get androidKeyaliasName() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('androidKeyaliasName') || '';
|
2020-07-06 01:41:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get androidKeyaliasPass() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('androidKeyaliasPass') || '';
|
2020-07-06 01:41:21 +00:00
|
|
|
}
|
|
|
|
|
|
2021-11-24 12:51:52 +00:00
|
|
|
static get androidTargetSdkVersion() {
|
|
|
|
|
return core.getInput('androidTargetSdkVersion') || '';
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-21 15:44:56 +00:00
|
|
|
static get allowDirtyBuild() {
|
2021-12-06 20:56:40 +00:00
|
|
|
const input = Input.getInput('allowDirtyBuild') || false;
|
2020-05-21 15:44:56 +00:00
|
|
|
|
2020-08-10 14:30:06 +00:00
|
|
|
return input === 'true';
|
2020-05-21 15:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get customParameters() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('customParameters') || '';
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
2020-08-09 19:27:47 +00:00
|
|
|
|
2021-05-28 21:51:10 +00:00
|
|
|
static get sshAgent() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('sshAgent') || '';
|
2021-05-28 21:51:10 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-29 18:15:23 +00:00
|
|
|
static async githubToken() {
|
|
|
|
|
return Input.getInput('githubToken') || (await GithubCliReader.GetGitHubAuthToken()) || '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static async gitPrivateToken() {
|
|
|
|
|
return core.getInput('gitPrivateToken') || (await GithubCliReader.GetGitHubAuthToken()) || '';
|
2021-11-14 22:52:35 +00:00
|
|
|
}
|
|
|
|
|
|
2021-05-01 23:23:15 +00:00
|
|
|
static get chownFilesTo() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('chownFilesTo') || '';
|
2021-05-01 23:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-15 20:45:22 +00:00
|
|
|
static get postBuildSteps() {
|
2021-12-13 22:21:26 +00:00
|
|
|
return Input.getInput('postBuildSteps') || '';
|
2021-08-15 20:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-21 23:26:03 +00:00
|
|
|
static get preBuildSteps() {
|
2021-12-13 22:21:26 +00:00
|
|
|
return Input.getInput('preBuildSteps') || '';
|
2021-08-21 23:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-30 00:25:32 +00:00
|
|
|
static get customJob() {
|
|
|
|
|
return Input.getInput('customJobs') || '';
|
2021-08-21 23:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-17 22:13:46 +00:00
|
|
|
static get cloudRunnerCluster() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('cloudRunnerCluster') || '';
|
2021-04-20 20:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-13 19:59:01 +00:00
|
|
|
static get awsBaseStackName() {
|
2021-12-19 22:35:28 +00:00
|
|
|
return Input.getInput('awsBaseStackName') || 'game-ci-3-test';
|
2021-04-20 20:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-09 19:27:47 +00:00
|
|
|
static get kubeConfig() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('kubeConfig') || '';
|
2020-08-09 19:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-17 22:13:46 +00:00
|
|
|
static get cloudRunnerMemory() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('cloudRunnerMemory') || '750M';
|
2020-08-09 19:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-17 22:13:46 +00:00
|
|
|
static get cloudRunnerCpu() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('cloudRunnerCpu') || '1.0';
|
2020-08-09 19:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get kubeVolumeSize() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('kubeVolumeSize') || '5Gi';
|
2020-08-09 19:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static get kubeVolume() {
|
2021-12-06 20:56:40 +00:00
|
|
|
return Input.getInput('kubeVolume') || '';
|
2020-08-09 19:27:47 +00:00
|
|
|
}
|
2019-12-22 14:05:15 +00:00
|
|
|
}
|
2020-01-20 23:06:14 +00:00
|
|
|
|
|
|
|
|
export default Input;
|