Default to root user with option to use host user
parent
1921dc4e1b
commit
30b936fecb
|
@ -101,6 +101,12 @@ inputs:
|
|||
required: false
|
||||
default: ''
|
||||
description: '[CloudRunner] GitHub owner name or organization/team name'
|
||||
runAsHostUser:
|
||||
required: false
|
||||
default: 'false'
|
||||
description:
|
||||
'Whether to run as a user that matches the host system or the default root container user. Only applicable to
|
||||
Linux hosts and containers. This is useful for fixing permission errors on Self-Hosted runners.'
|
||||
chownFilesTo:
|
||||
required: false
|
||||
default: ''
|
||||
|
|
|
@ -312,6 +312,7 @@ class BuildParameters {
|
|||
sshAgent: input_1.default.sshAgent,
|
||||
sshPublicKeysDirectoryPath: input_1.default.sshPublicKeysDirectoryPath,
|
||||
gitPrivateToken: input_1.default.gitPrivateToken || (await github_cli_1.GithubCliReader.GetGitHubAuthToken()),
|
||||
runAsHostUser: input_1.default.runAsHostUser,
|
||||
chownFilesTo: input_1.default.chownFilesTo,
|
||||
dockerCpuLimit: input_1.default.dockerCpuLimit,
|
||||
dockerMemoryLimit: input_1.default.dockerMemoryLimit,
|
||||
|
@ -6337,6 +6338,7 @@ class ImageEnvironmentFactory {
|
|||
{ name: 'ANDROID_EXPORT_TYPE', value: parameters.androidExportType },
|
||||
{ name: 'ANDROID_SYMBOL_TYPE', value: parameters.androidSymbolType },
|
||||
{ name: 'CUSTOM_PARAMETERS', value: parameters.customParameters },
|
||||
{ name: 'RUN_AS_HOST_USER', value: parameters.runAsHostUser },
|
||||
{ name: 'CHOWN_FILES_TO', value: parameters.chownFilesTo },
|
||||
{ name: 'GITHUB_REF', value: process.env.GITHUB_REF },
|
||||
{ name: 'GITHUB_SHA', value: process.env.GITHUB_SHA },
|
||||
|
@ -6908,6 +6910,9 @@ class Input {
|
|||
static get gitPrivateToken() {
|
||||
return Input.getInput('gitPrivateToken');
|
||||
}
|
||||
static get runAsHostUser() {
|
||||
return Input.getInput('runAsHostUser') || 'false';
|
||||
}
|
||||
static get chownFilesTo() {
|
||||
return Input.getInput('chownFilesTo') || '';
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -52,7 +52,12 @@ else
|
|||
echo "Not updating Android SDK."
|
||||
fi
|
||||
|
||||
# Switch to the host user so we can create files with the correct ownership
|
||||
su $USERNAME -c "$SHELL -c 'source /steps/runsteps.sh'"
|
||||
if [[ "RUN_AS_HOST_USER" == "true" ]]; then
|
||||
# Switch to the host user so we can create files with the correct ownership
|
||||
su $USERNAME -c "$SHELL -c 'source /steps/runsteps.sh'"
|
||||
else
|
||||
# Run as root
|
||||
source /steps/runsteps.sh
|
||||
fi
|
||||
|
||||
exit $?
|
||||
|
|
|
@ -59,6 +59,7 @@ class BuildParameters {
|
|||
public kubeVolumeSize!: string;
|
||||
public kubeVolume!: string;
|
||||
public kubeStorageClass!: string;
|
||||
public runAsHostUser!: String;
|
||||
public chownFilesTo!: string;
|
||||
public commandHooks!: string;
|
||||
public pullInputList!: string[];
|
||||
|
@ -168,6 +169,7 @@ class BuildParameters {
|
|||
sshAgent: Input.sshAgent,
|
||||
sshPublicKeysDirectoryPath: Input.sshPublicKeysDirectoryPath,
|
||||
gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()),
|
||||
runAsHostUser: Input.runAsHostUser,
|
||||
chownFilesTo: Input.chownFilesTo,
|
||||
dockerCpuLimit: Input.dockerCpuLimit,
|
||||
dockerMemoryLimit: Input.dockerMemoryLimit,
|
||||
|
|
|
@ -62,6 +62,7 @@ class ImageEnvironmentFactory {
|
|||
{ name: 'ANDROID_EXPORT_TYPE', value: parameters.androidExportType },
|
||||
{ name: 'ANDROID_SYMBOL_TYPE', value: parameters.androidSymbolType },
|
||||
{ name: 'CUSTOM_PARAMETERS', value: parameters.customParameters },
|
||||
{ name: 'RUN_AS_HOST_USER', value: parameters.runAsHostUser },
|
||||
{ name: 'CHOWN_FILES_TO', value: parameters.chownFilesTo },
|
||||
{ name: 'GITHUB_REF', value: process.env.GITHUB_REF },
|
||||
{ name: 'GITHUB_SHA', value: process.env.GITHUB_SHA },
|
||||
|
|
|
@ -193,6 +193,10 @@ class Input {
|
|||
return Input.getInput('gitPrivateToken');
|
||||
}
|
||||
|
||||
static get runAsHostUser(): string {
|
||||
return Input.getInput('runAsHostUser') || 'false';
|
||||
}
|
||||
|
||||
static get chownFilesTo() {
|
||||
return Input.getInput('chownFilesTo') || '';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue