Compare commits

..

3 Commits

Author SHA1 Message Date
David Finol
420863deca Fix Android cmdline-tools path 2023-09-25 21:20:29 -05:00
Toby Harris
a13443a746 manualExit suppresses -quit, useful for buildMethods with async calls (#574)
* `manualExit` suppresses `-quit`, useful for buildMethods with async calls

* Use boolean
2023-09-20 23:41:17 +02:00
Ely Ronnen
2190fd5667 Support multiple GitHub SSH deploy keys (#568)
* add sshPublicKeysDirectoryPath and GIT_CONFIG_EXTENSIONS parameters that adds git configs and mounts .ssh/config and public keys to the container, in order to allow multiple sh deploy key trick by webplatform@ssh-agent

* remove sshPublicKeysDirectoryPath and GIT_CONFIG_EXTENSIONS from windows runner for now
2023-09-06 23:35:24 +02:00
11 changed files with 106 additions and 7 deletions

View File

@@ -31,6 +31,10 @@ inputs:
required: false
default: ''
description: 'Path to a Namespace.Class.StaticMethod to run to perform the build.'
manualExit:
required: false
default: ''
description: 'Suppresses `-quit`. Exit your build method using `EditorApplication.Exit(0)` instead.'
customParameters:
required: false
default: ''
@@ -85,6 +89,10 @@ inputs:
required: false
default: ''
description: 'SSH Agent path to forward to the container'
sshPublicKeysDirectoryPath:
required: false
default: ''
description: 'Path to a directory containing SSH public keys to forward to the container.'
gitPrivateToken:
required: false
default: ''

18
dist/index.js generated vendored
View File

@@ -265,6 +265,7 @@ class BuildParameters {
buildFile,
buildMethod: input_1.default.buildMethod,
buildVersion,
manualExit: input_1.default.manualExit,
androidVersionCode,
androidKeystoreName: input_1.default.androidKeystoreName,
androidKeystoreBase64: input_1.default.androidKeystoreBase64,
@@ -277,6 +278,7 @@ class BuildParameters {
androidSymbolType: androidSymbolExportType,
customParameters: input_1.default.customParameters,
sshAgent: input_1.default.sshAgent,
sshPublicKeysDirectoryPath: input_1.default.sshPublicKeysDirectoryPath,
gitPrivateToken: input_1.default.gitPrivateToken || (await github_cli_1.GithubCliReader.GetGitHubAuthToken()),
chownFilesTo: input_1.default.chownFilesTo,
providerStrategy: cloud_runner_options_1.default.providerStrategy,
@@ -5880,7 +5882,7 @@ class Docker {
}
}
static getLinuxCommand(image, parameters, overrideCommands = '', additionalVariables = [], entrypointBash = false) {
const { workspace, actionFolder, runnerTempPath, sshAgent, gitPrivateToken, dockerWorkspacePath } = parameters;
const { workspace, actionFolder, runnerTempPath, sshAgent, sshPublicKeysDirectoryPath, gitPrivateToken, dockerWorkspacePath, } = parameters;
const githubHome = node_path_1.default.join(runnerTempPath, '_github_home');
if (!(0, node_fs_1.existsSync)(githubHome))
(0, node_fs_1.mkdirSync)(githubHome);
@@ -5894,6 +5896,7 @@ class Docker {
${image_environment_factory_1.default.getEnvVarString(parameters, additionalVariables)} \
--env UNITY_SERIAL \
--env GITHUB_WORKSPACE=${dockerWorkspacePath} \
--env GIT_CONFIG_EXTENSIONS \
${gitPrivateToken ? `--env GIT_PRIVATE_TOKEN="${gitPrivateToken}"` : ''} \
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
--volume "${githubHome}":"/root:z" \
@@ -5904,7 +5907,10 @@ class Docker {
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
--volume "${actionFolder}/unity-config:/usr/share/unity3d/config/:z" \
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
${sshAgent && !sshPublicKeysDirectoryPath
? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro'
: ''} \
${sshPublicKeysDirectoryPath ? `--volume ${sshPublicKeysDirectoryPath}:/root/.ssh:ro` : ''} \
${entrypointBash ? `--entrypoint ${commandPrefix}` : ``} \
${image} \
${entrypointBash ? `-c` : `${commandPrefix} -c`} \
@@ -6264,6 +6270,7 @@ class ImageEnvironmentFactory {
{ name: 'BUILD_PATH', value: parameters.buildPath },
{ name: 'BUILD_FILE', value: parameters.buildFile },
{ name: 'BUILD_METHOD', value: parameters.buildMethod },
{ name: 'MANUAL_EXIT', value: parameters.manualExit },
{ name: 'VERSION', value: parameters.buildVersion },
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },
@@ -6823,6 +6830,10 @@ class Input {
static get buildMethod() {
return Input.getInput('buildMethod') || ''; // Processed in docker file
}
static get manualExit() {
const input = Input.getInput('manualExit') || false;
return input === 'true';
}
static get customParameters() {
return Input.getInput('customParameters') || '';
}
@@ -6862,6 +6873,9 @@ class Input {
static get sshAgent() {
return Input.getInput('sshAgent') || '';
}
static get sshPublicKeysDirectoryPath() {
return Input.getInput('sshPublicKeysDirectoryPath') || '';
}
static get gitPrivateToken() {
return Input.getInput('gitPrivateToken');
}

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -10,6 +10,7 @@ mkdir -p "$ACTIVATE_LICENSE_PATH"
#
# Run steps
#
source /steps/set_extra_git_configs.sh
source /steps/set_gitcredential.sh
source /steps/activate.sh
source /steps/build.sh

View File

@@ -69,7 +69,7 @@ fi
if [[ "$BUILD_TARGET" == "Android" && -n "$ANDROID_SDK_MANAGER_PARAMETERS" ]]; then
echo "Updating Android SDK with parameters: $ANDROID_SDK_MANAGER_PARAMETERS"
export JAVA_HOME="$(awk -F'=' '/JAVA_HOME=/{print $2}' /usr/bin/unity-editor.d/*)"
"$(awk -F'=' '/ANDROID_HOME=/{print $2}' /usr/bin/unity-editor.d/*)/tools/bin/sdkmanager" "$ANDROID_SDK_MANAGER_PARAMETERS"
"$(awk -F'=' '/ANDROID_HOME=/{print $2}' /usr/bin/unity-editor.d/*)/cmdline-tools/6.0/bin/sdkmanager" "$ANDROID_SDK_MANAGER_PARAMETERS"
echo "Updated Android SDK."
else
echo "Not updating Android SDK."
@@ -119,7 +119,7 @@ echo ""
unity-editor \
-logfile /dev/stdout \
-quit \
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
-customBuildName "$BUILD_NAME" \
-projectPath "$UNITY_PROJECT_PATH" \
-buildTarget "$BUILD_TARGET" \

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
if [ -z "${GIT_CONFIG_EXTENSIONS}" ]
then
echo "GIT_CONFIG_EXTENSIONS unset skipping"
else
echo "GIT_CONFIG_EXTENSIONS is set configuring extra git configs"
IFS=$'\n'
for config in $(echo "${GIT_CONFIG_EXTENSIONS}" | sed 's/\(.*\)=\(.*\)/"\1" "\2"/g'); do
if [[ $config =~ \"([^\"]+)\"\ \"([^\"]+)\" ]]; then
key="${BASH_REMATCH[1]}"
value="${BASH_REMATCH[2]}"
else
echo "Error parsing config: $config"
exit 1
fi
echo "Adding extra git config: \"$key\" = \"$value\""
git config --global --add "$key" "$value"
done
unset IFS
fi
echo "---------- git config --list -------------"
git config --list
echo "---------- git config --list --show-origin -------------"
git config --list --show-origin

View File

@@ -29,6 +29,7 @@ class BuildParameters {
public buildFile!: string;
public buildMethod!: string;
public buildVersion!: string;
public manualExit!: boolean;
public androidVersionCode!: string;
public androidKeystoreName!: string;
public androidKeystoreBase64!: string;
@@ -42,6 +43,7 @@ class BuildParameters {
public customParameters!: string;
public sshAgent!: string;
public sshPublicKeysDirectoryPath!: string;
public providerStrategy!: string;
public gitPrivateToken!: string;
public awsStackName!: string;
@@ -138,6 +140,7 @@ class BuildParameters {
buildFile,
buildMethod: Input.buildMethod,
buildVersion,
manualExit: Input.manualExit,
androidVersionCode,
androidKeystoreName: Input.androidKeystoreName,
androidKeystoreBase64: Input.androidKeystoreBase64,
@@ -150,6 +153,7 @@ class BuildParameters {
androidSymbolType: androidSymbolExportType,
customParameters: Input.customParameters,
sshAgent: Input.sshAgent,
sshPublicKeysDirectoryPath: Input.sshPublicKeysDirectoryPath,
gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()),
chownFilesTo: Input.chownFilesTo,
providerStrategy: CloudRunnerOptions.providerStrategy,

View File

@@ -40,7 +40,15 @@ class Docker {
additionalVariables: StringKeyValuePair[] = [],
entrypointBash: boolean = false,
): string {
const { workspace, actionFolder, runnerTempPath, sshAgent, gitPrivateToken, dockerWorkspacePath } = parameters;
const {
workspace,
actionFolder,
runnerTempPath,
sshAgent,
sshPublicKeysDirectoryPath,
gitPrivateToken,
dockerWorkspacePath,
} = parameters;
const githubHome = path.join(runnerTempPath, '_github_home');
if (!existsSync(githubHome)) mkdirSync(githubHome);
@@ -54,6 +62,7 @@ class Docker {
${ImageEnvironmentFactory.getEnvVarString(parameters, additionalVariables)} \
--env UNITY_SERIAL \
--env GITHUB_WORKSPACE=${dockerWorkspacePath} \
--env GIT_CONFIG_EXTENSIONS \
${gitPrivateToken ? `--env GIT_PRIVATE_TOKEN="${gitPrivateToken}"` : ''} \
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
--volume "${githubHome}":"/root:z" \
@@ -64,7 +73,12 @@ class Docker {
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
--volume "${actionFolder}/unity-config:/usr/share/unity3d/config/:z" \
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
${
sshAgent && !sshPublicKeysDirectoryPath
? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro'
: ''
} \
${sshPublicKeysDirectoryPath ? `--volume ${sshPublicKeysDirectoryPath}:/root/.ssh:ro` : ''} \
${entrypointBash ? `--entrypoint ${commandPrefix}` : ``} \
${image} \
${entrypointBash ? `-c` : `${commandPrefix} -c`} \

View File

@@ -37,6 +37,7 @@ class ImageEnvironmentFactory {
{ name: 'BUILD_PATH', value: parameters.buildPath },
{ name: 'BUILD_FILE', value: parameters.buildFile },
{ name: 'BUILD_METHOD', value: parameters.buildMethod },
{ name: 'MANUAL_EXIT', value: parameters.manualExit },
{ name: 'VERSION', value: parameters.buildVersion },
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },

View File

@@ -104,6 +104,24 @@ describe('Input', () => {
});
});
describe('manualExit', () => {
it('returns the default value', () => {
expect(Input.manualExit).toStrictEqual(false);
});
it('returns true when string true is passed', () => {
const spy = jest.spyOn(core, 'getInput').mockReturnValue('true');
expect(Input.manualExit).toStrictEqual(true);
expect(spy).toHaveBeenCalledTimes(1);
});
it('returns false when string false is passed', () => {
const spy = jest.spyOn(core, 'getInput').mockReturnValue('false');
expect(Input.manualExit).toStrictEqual(false);
expect(spy).toHaveBeenCalledTimes(1);
});
});
describe('versioningStrategy', () => {
it('returns the default value', () => {
expect(Input.versioningStrategy).toStrictEqual('Semantic');

View File

@@ -126,6 +126,12 @@ class Input {
return Input.getInput('buildMethod') || ''; // Processed in docker file
}
static get manualExit(): boolean {
const input = Input.getInput('manualExit') || false;
return input === 'true';
}
static get customParameters(): string {
return Input.getInput('customParameters') || '';
}
@@ -178,6 +184,10 @@ class Input {
return Input.getInput('sshAgent') || '';
}
static get sshPublicKeysDirectoryPath(): string {
return Input.getInput('sshPublicKeysDirectoryPath') || '';
}
static get gitPrivateToken(): string | undefined {
return Input.getInput('gitPrivateToken');
}