diff --git a/action.yml b/action.yml index 2ada25e6..42778847 100644 --- a/action.yml +++ b/action.yml @@ -124,6 +124,14 @@ inputs: 'Isolation mode to use for the docker container. Can be one of process, hyperv, or default. Default will pick the default mode as described by Microsoft where server versions use process and desktop versions use hyperv. Only applicable on Windows' + containerRegistryRepository: + required: false + default: 'unityci/editor' + description: 'Container registry url to pull image from. Only applicable if customImage is not set.' + containerRegistryImageVersion: + required: false + default: '3' + description: 'Container registry image version. Only applicable if customImage is not set.' allowDirtyBuild: required: false default: '' diff --git a/dist/index.js b/dist/index.js index 1753a290..4ddfc66b 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index e840b3fe..138b2544 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/src/model/build-parameters.ts b/src/model/build-parameters.ts index 4cd8a523..a91e165e 100644 --- a/src/model/build-parameters.ts +++ b/src/model/build-parameters.ts @@ -44,6 +44,8 @@ class BuildParameters { public dockerCpuLimit!: string; public dockerMemoryLimit!: string; public dockerIsolationMode!: string; + public containerRegistryRepository!: string; + public containerRegistryImageVersion!: string; public customParameters!: string; public sshAgent!: string; @@ -170,6 +172,8 @@ class BuildParameters { dockerCpuLimit: Input.dockerCpuLimit, dockerMemoryLimit: Input.dockerMemoryLimit, dockerIsolationMode: Input.dockerIsolationMode, + containerRegistryRepository: Input.containerRegistryRepository, + containerRegistryImageVersion: Input.containerRegistryImageVersion, providerStrategy: CloudRunnerOptions.providerStrategy, buildPlatform: CloudRunnerOptions.buildPlatform, kubeConfig: CloudRunnerOptions.kubeConfig, diff --git a/src/model/image-tag.test.ts b/src/model/image-tag.test.ts index 77934e5d..47adf65e 100644 --- a/src/model/image-tag.test.ts +++ b/src/model/image-tag.test.ts @@ -5,11 +5,11 @@ describe('ImageTag', () => { editorVersion: '2099.9.f9f9', targetPlatform: 'Test', builderPlatform: '', + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }; const defaults = { - repository: 'unityci', - name: 'editor', image: 'unityci/editor', }; @@ -21,8 +21,7 @@ describe('ImageTag', () => { it('accepts parameters and sets the right properties', () => { const image = new ImageTag(testImageParameters); - expect(image.repository).toStrictEqual('unityci'); - expect(image.name).toStrictEqual('editor'); + expect(image.repository).toStrictEqual('unityci/editor'); expect(image.editorVersion).toStrictEqual(testImageParameters.editorVersion); expect(image.targetPlatform).toStrictEqual(testImageParameters.targetPlatform); expect(image.builderPlatform).toStrictEqual(testImageParameters.builderPlatform); @@ -53,6 +52,8 @@ describe('ImageTag', () => { const image = new ImageTag({ editorVersion: '2099.1.1111', targetPlatform: testImageParameters.targetPlatform, + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }); switch (process.platform) { case 'win32': @@ -68,6 +69,8 @@ describe('ImageTag', () => { editorVersion: '2099.1.1111', targetPlatform: testImageParameters.targetPlatform, customImage: `${defaults.image}:2099.1.1111@347598437689743986`, + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }); expect(image.toString()).toStrictEqual(image.customImage); @@ -77,6 +80,8 @@ describe('ImageTag', () => { const image = new ImageTag({ editorVersion: '2019.2.11f1', targetPlatform: 'WebGL', + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }); switch (process.platform) { @@ -93,6 +98,8 @@ describe('ImageTag', () => { const image = new ImageTag({ editorVersion: '2019.2.11f1', targetPlatform: 'NoTarget', + containerRegistryRepository: 'unityci/editor', + containerRegistryImageVersion: '3', }); switch (process.platform) { diff --git a/src/model/image-tag.ts b/src/model/image-tag.ts index 35b4bbeb..cf484708 100644 --- a/src/model/image-tag.ts +++ b/src/model/image-tag.ts @@ -2,7 +2,6 @@ import Platform from './platform'; class ImageTag { public repository: string; - public name: string; public cloudRunnerBuilderPlatform!: string; public editorVersion: string; public targetPlatform: string; @@ -12,7 +11,14 @@ class ImageTag { public imagePlatformPrefix: string; constructor(imageProperties: { [key: string]: string }) { - const { editorVersion, targetPlatform, customImage, cloudRunnerBuilderPlatform } = imageProperties; + const { + editorVersion, + targetPlatform, + customImage, + cloudRunnerBuilderPlatform, + containerRegistryRepository, + containerRegistryImageVersion, + } = imageProperties; if (!ImageTag.versionPattern.test(editorVersion)) { throw new Error(`Invalid version "${editorVersion}".`); @@ -23,8 +29,7 @@ class ImageTag { this.customImage = customImage; // Or - this.repository = 'unityci'; - this.name = 'editor'; + this.repository = containerRegistryRepository; this.editorVersion = editorVersion; this.targetPlatform = targetPlatform; this.cloudRunnerBuilderPlatform = cloudRunnerBuilderPlatform; @@ -33,7 +38,7 @@ class ImageTag { this.imagePlatformPrefix = ImageTag.getImagePlatformPrefixes( isCloudRunnerLocal ? process.platform : cloudRunnerBuilderPlatform, ); - this.imageRollingVersion = 3; // Will automatically roll to the latest non-breaking version. + this.imageRollingVersion = Number(containerRegistryImageVersion); // Will automatically roll to the latest non-breaking version. } static get versionPattern(): RegExp { @@ -156,7 +161,7 @@ class ImageTag { } get image(): string { - return `${this.repository}/${this.name}`.replace(/^\/+/, ''); + return `${this.repository}`.replace(/^\/+/, ''); } toString(): string { diff --git a/src/model/input.ts b/src/model/input.ts index 94a0f2b4..7733ea1f 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -256,6 +256,14 @@ class Input { return Input.getInput('dockerIsolationMode') || 'default'; } + static get containerRegistryRepository(): string { + return Input.getInput('containerRegistryUrl')!; + } + + static get containerRegistryImageVersion(): string { + return Input.getInput('containerRegistryImageVersion')!; + } + public static ToEnvVarFormat(input: string) { if (input.toUpperCase() === input) { return input;