diff --git a/action.yml b/action.yml index 989c2569..121174df 100644 --- a/action.yml +++ b/action.yml @@ -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: '' diff --git a/dist/index.js b/dist/index.js index dc3aac42..f55c9a57 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 6f16cb34..c72ad08f 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/dist/platforms/ubuntu/entrypoint.sh b/dist/platforms/ubuntu/entrypoint.sh index 9a22c8e9..04cab042 100755 --- a/dist/platforms/ubuntu/entrypoint.sh +++ b/dist/platforms/ubuntu/entrypoint.sh @@ -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 $? diff --git a/src/model/build-parameters.ts b/src/model/build-parameters.ts index a91e165e..6710a4da 100644 --- a/src/model/build-parameters.ts +++ b/src/model/build-parameters.ts @@ -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, diff --git a/src/model/image-environment-factory.ts b/src/model/image-environment-factory.ts index 6162b50b..2df52f1a 100644 --- a/src/model/image-environment-factory.ts +++ b/src/model/image-environment-factory.ts @@ -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 }, diff --git a/src/model/input.ts b/src/model/input.ts index 85f45733..c12abe00 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -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') || ''; }