From 119946da75741f49e36aa25e9ee18a2a9fac5c3b Mon Sep 17 00:00:00 2001 From: Ejnar Arechavala Date: Wed, 7 Aug 2024 12:01:49 -0700 Subject: [PATCH] Add licensingProductIds param & update services-config template --- action.yml | 7 +++++++ dist/unity-config/services-config.json.template | 3 ++- src/main.ts | 2 ++ src/model/docker.ts | 6 +++++- src/model/image-environment-factory.ts | 1 + src/model/input.ts | 2 ++ src/model/licensing-server-setup.ts | 7 ++++++- 7 files changed, 25 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 380b0906..5abf5f68 100644 --- a/action.yml +++ b/action.yml @@ -90,6 +90,13 @@ inputs: required: false default: '' description: 'Url to a unity license server for acquiring floating licenses.' + unityLicensingProductIds: + required: false + default: '' + description: + 'Comma separated list of license product identifiers to request licenses for from the license server. Not setting + this will request the default license product configured on the licensing server. Only applicable if + unityLicensingServer is set.' containerRegistryRepository: required: false default: 'unityci/editor' diff --git a/dist/unity-config/services-config.json.template b/dist/unity-config/services-config.json.template index 5a868f1b..9e685bf6 100644 --- a/dist/unity-config/services-config.json.template +++ b/dist/unity-config/services-config.json.template @@ -3,5 +3,6 @@ "enableEntitlementLicensing": true, "enableFloatingApi": true, "clientConnectTimeoutSec": 5, - "clientHandshakeTimeoutSec": 10 + "clientHandshakeTimeoutSec": 10, + "toolset": "%LICENSE_PRODUCT_IDS%" } diff --git a/src/main.ts b/src/main.ts index 4922b35a..ff7d8f16 100644 --- a/src/main.ts +++ b/src/main.ts @@ -29,6 +29,7 @@ export async function run() { dockerMemoryLimit, dockerIsolationMode, unityLicensingServer, + unityLicensingProductIds, runAsHostUser, containerRegistryRepository, containerRegistryImageVersion, @@ -66,6 +67,7 @@ export async function run() { dockerMemoryLimit, dockerIsolationMode, unityLicensingServer, + unityLicensingProductIds, runAsHostUser, unitySerial, ...runnerContext, diff --git a/src/model/docker.ts b/src/model/docker.ts index 411b9e7d..7033be49 100644 --- a/src/model/docker.ts +++ b/src/model/docker.ts @@ -34,7 +34,11 @@ const Docker = { let runCommand = ''; if (parameters.unityLicensingServer !== '') { - LicensingServerSetup.Setup(parameters.unityLicensingServer, parameters.actionFolder); + LicensingServerSetup.Setup( + parameters.unityLicensingServer, + parameters.actionFolder, + parameters.unityLicensingProductIds, + ); } switch (process.platform) { diff --git a/src/model/image-environment-factory.ts b/src/model/image-environment-factory.ts index 2d8450e7..5ed17949 100644 --- a/src/model/image-environment-factory.ts +++ b/src/model/image-environment-factory.ts @@ -27,6 +27,7 @@ class ImageEnvironmentFactory { name: 'UNITY_LICENSING_SERVER', value: parameters.unityLicensingServer, }, + { name: 'UNITY_LICENSING_PRODUCT_IDS', value: parameters.unityLicensingProductIds }, { name: 'UNITY_VERSION', value: parameters.editorVersion }, { name: 'USYM_UPLOAD_AUTH_TOKEN', diff --git a/src/model/input.ts b/src/model/input.ts index 3c23c05b..dbc66d71 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -87,6 +87,7 @@ class Input { const customImage = getInput('customImage') || ''; const rawProjectPath = getInput('projectPath') || '.'; const unityLicensingServer = getInput('unityLicensingServer') || ''; + const unityLicensingProductIds = getInput('unityLicensingProductIds') || ''; const unityLicense = getInput('unityLicense') || (process.env['UNITY_LICENSE'] ?? ''); let unitySerial = process.env['UNITY_SERIAL'] ?? ''; const customParameters = getInput('customParameters') || ''; @@ -239,6 +240,7 @@ class Input { dockerMemoryLimit, dockerIsolationMode, unityLicensingServer, + unityLicensingProductIds, runAsHostUser, containerRegistryRepository, containerRegistryImageVersion, diff --git a/src/model/licensing-server-setup.ts b/src/model/licensing-server-setup.ts index 7d52267f..b7ccb21f 100644 --- a/src/model/licensing-server-setup.ts +++ b/src/model/licensing-server-setup.ts @@ -2,7 +2,11 @@ import fs from 'fs'; class LicensingServerSetup { - public static Setup(unityLicensingServer, actionFolder: string) { + public static Setup( + unityLicensingServer, + actionFolder: string, + unityLicensingProductIds: string, + ) { const servicesConfigPath = `${actionFolder}/unity-config/services-config.json`; const servicesConfigPathTemplate = `${servicesConfigPath}.template`; if (!fs.existsSync(servicesConfigPathTemplate)) { @@ -13,6 +17,7 @@ class LicensingServerSetup { let servicesConfig = fs.readFileSync(servicesConfigPathTemplate).toString(); servicesConfig = servicesConfig.replace('%URL%', unityLicensingServer); + servicesConfig = servicesConfig.replace('%LICENSE_PRODUCT_IDS%', unityLicensingProductIds); fs.writeFileSync(servicesConfigPath, servicesConfig); } }