Skip to content

Commit

Permalink
Chown files to a custom user after building (fix file ownership) (#250)
Browse files Browse the repository at this point in the history
* Chown files to a custom user after building

* Better describe `chownFilesTo` input

As suggested by @webbertakken: #250 (comment)

Co-authored-by: Webber Takken <[email protected]>

* Simplify chown step in `build.sh`

Co-authored-by: Webber Takken <[email protected]>

Co-authored-by: Webber Takken <[email protected]>
  • Loading branch information
Bradshaw and webbertakken authored May 1, 2021
1 parent a1f68ab commit e31af20
Show file tree
Hide file tree
Showing 10 changed files with 532 additions and 493 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down
997 changes: 505 additions & 492 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions dist/steps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
1 change: 1 addition & 0 deletions src/model/__mocks__/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const mockGetFromUser = jest.fn().mockResolvedValue({
buildMethod: undefined,
buildVersion: '1.3.37',
customParameters: '',
chownFilesTo: '',
});

export default {
Expand Down
4 changes: 4 additions & 0 deletions src/model/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/model/build-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/model/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Docker {
androidKeyaliasName,
androidKeyaliasPass,
customParameters,
chownFilesTo,
} = parameters;

const command = `docker run \
Expand All @@ -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 \
Expand Down
4 changes: 4 additions & 0 deletions src/model/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class Input {
return core.getInput('customParameters') || '';
}

static get chownFilesTo() {
return core.getInput('chownFilesTo') || '';
}

static get remoteBuildCluster() {
return core.getInput('remoteBuildCluster') || '';
}
Expand Down
4 changes: 4 additions & 0 deletions src/model/kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e31af20

Please sign in to comment.