Chown files to a custom user after building (fix file ownership) (#250)

* Chown files to a custom user after building

* Better describe `chownFilesTo` input

As suggested by @webbertakken: https://github.com/game-ci/unity-builder/pull/250#discussion_r624575666

Co-authored-by: Webber Takken <webber@takken.io>

* Simplify chown step in `build.sh`

Co-authored-by: Webber Takken <webber@takken.io>

Co-authored-by: Webber Takken <webber@takken.io>
This commit is contained in:
Gaeel Bradshaw-Rodriguez 2021-05-02 01:23:15 +02:00 committed by GitHub
parent a1f68ab26c
commit e31af20466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 26 additions and 0 deletions

View File

@ -106,6 +106,10 @@ inputs:
Parameters must start with a hyphen (-) and may be followed by a value (without hyphen).
Parameters without a value will be considered booleans (with a value of true).
chownFilesTo:
required: false
default: ''
description: 'User and optionally group (user or user:group or uid:gid) to give ownership of the resulting build artifacts'
allowDirtyBuild:
required: false
default: ''

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

6
dist/steps/build.sh vendored
View File

@ -143,6 +143,12 @@ if [[ "$BUILD_TARGET" == "StandaloneOSX" ]]; then
chmod +x $ADD_PERMISSIONS_PATH
fi
if [[ -n "$CHOWN_FILES_TO" ]]; then
chown -R $CHOWN_FILES_TO $BUILD_PATH_FULL
chown -R $CHOWN_FILES_TO $UNITY_PROJECT_PATH
fi
#
# Results
#

View File

@ -10,6 +10,7 @@ export const mockGetFromUser = jest.fn().mockResolvedValue({
buildMethod: undefined,
buildVersion: '1.3.37',
customParameters: '',
chownFilesTo: '',
});
export default {

View File

@ -149,6 +149,10 @@ class AWS {
name: 'CUSTOM_PARAMETERS',
value: buildParameters.customParameters,
},
{
name: 'CHOWN_FILES_TO',
value: buildParameters.chownFilesTo,
},
{
name: 'BUILD_TARGET',
value: buildParameters.platform,

View File

@ -33,6 +33,7 @@ class BuildParameters {
androidKeyaliasName: Input.androidKeyaliasName,
androidKeyaliasPass: Input.androidKeyaliasPass,
customParameters: Input.customParameters,
chownFilesTo: Input.chownFilesTo,
remoteBuildCluster: Input.remoteBuildCluster,
awsStackName: Input.awsStackName,
kubeConfig: Input.kubeConfig,

View File

@ -36,6 +36,7 @@ class Docker {
androidKeyaliasName,
androidKeyaliasPass,
customParameters,
chownFilesTo,
} = parameters;
const command = `docker run \
@ -62,6 +63,7 @@ class Docker {
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env CHOWN_FILES_TO="${chownFilesTo}" \
--env GITHUB_REF \
--env GITHUB_SHA \
--env GITHUB_REPOSITORY \

View File

@ -85,6 +85,10 @@ class Input {
return core.getInput('customParameters') || '';
}
static get chownFilesTo() {
return core.getInput('chownFilesTo') || '';
}
static get remoteBuildCluster() {
return core.getInput('remoteBuildCluster') || '';
}

View File

@ -222,6 +222,10 @@ class Kubernetes {
name: 'CUSTOM_PARAMETERS',
value: this.buildParameters.customParameters,
},
{
name: 'CHOWN_FILES_TO',
value: this.buildParameters.chownFilesTo,
},
{
name: 'BUILD_TARGET',
value: this.buildParameters.platform,