Skip to content

Commit e31af20

Browse files
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: #250 (comment) 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>
1 parent a1f68ab commit e31af20

File tree

10 files changed

+532
-493
lines changed

10 files changed

+532
-493
lines changed

action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ inputs:
106106
107107
Parameters must start with a hyphen (-) and may be followed by a value (without hyphen).
108108
Parameters without a value will be considered booleans (with a value of true).
109+
chownFilesTo:
110+
required: false
111+
default: ''
112+
description: 'User and optionally group (user or user:group or uid:gid) to give ownership of the resulting build artifacts'
109113
allowDirtyBuild:
110114
required: false
111115
default: ''

dist/index.js

+505-492
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/steps/build.sh

+6
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ if [[ "$BUILD_TARGET" == "StandaloneOSX" ]]; then
143143
chmod +x $ADD_PERMISSIONS_PATH
144144
fi
145145

146+
147+
if [[ -n "$CHOWN_FILES_TO" ]]; then
148+
chown -R $CHOWN_FILES_TO $BUILD_PATH_FULL
149+
chown -R $CHOWN_FILES_TO $UNITY_PROJECT_PATH
150+
fi
151+
146152
#
147153
# Results
148154
#

src/model/__mocks__/input.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const mockGetFromUser = jest.fn().mockResolvedValue({
1010
buildMethod: undefined,
1111
buildVersion: '1.3.37',
1212
customParameters: '',
13+
chownFilesTo: '',
1314
});
1415

1516
export default {

src/model/aws.ts

+4
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ class AWS {
149149
name: 'CUSTOM_PARAMETERS',
150150
value: buildParameters.customParameters,
151151
},
152+
{
153+
name: 'CHOWN_FILES_TO',
154+
value: buildParameters.chownFilesTo,
155+
},
152156
{
153157
name: 'BUILD_TARGET',
154158
value: buildParameters.platform,

src/model/build-parameters.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class BuildParameters {
3333
androidKeyaliasName: Input.androidKeyaliasName,
3434
androidKeyaliasPass: Input.androidKeyaliasPass,
3535
customParameters: Input.customParameters,
36+
chownFilesTo: Input.chownFilesTo,
3637
remoteBuildCluster: Input.remoteBuildCluster,
3738
awsStackName: Input.awsStackName,
3839
kubeConfig: Input.kubeConfig,

src/model/docker.ts

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Docker {
3636
androidKeyaliasName,
3737
androidKeyaliasPass,
3838
customParameters,
39+
chownFilesTo,
3940
} = parameters;
4041

4142
const command = `docker run \
@@ -62,6 +63,7 @@ class Docker {
6263
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
6364
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
6465
--env CUSTOM_PARAMETERS="${customParameters}" \
66+
--env CHOWN_FILES_TO="${chownFilesTo}" \
6567
--env GITHUB_REF \
6668
--env GITHUB_SHA \
6769
--env GITHUB_REPOSITORY \

src/model/input.ts

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ class Input {
8585
return core.getInput('customParameters') || '';
8686
}
8787

88+
static get chownFilesTo() {
89+
return core.getInput('chownFilesTo') || '';
90+
}
91+
8892
static get remoteBuildCluster() {
8993
return core.getInput('remoteBuildCluster') || '';
9094
}

src/model/kubernetes.ts

+4
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ class Kubernetes {
222222
name: 'CUSTOM_PARAMETERS',
223223
value: this.buildParameters.customParameters,
224224
},
225+
{
226+
name: 'CHOWN_FILES_TO',
227+
value: this.buildParameters.chownFilesTo,
228+
},
225229
{
226230
name: 'BUILD_TARGET',
227231
value: this.buildParameters.platform,

0 commit comments

Comments
 (0)