Skip to content

Commit

Permalink
revert Fix file ownership issues for self-hosted runners. (game-ci#141)…
Browse files Browse the repository at this point in the history
  • Loading branch information
caiusno1 authored Oct 22, 2020
1 parent ef74241 commit e6d3dae
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 30 deletions.
10 changes: 0 additions & 10 deletions action/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
ARG IMAGE
FROM $IMAGE

ARG UNAME=runner
ARG UID=1000
ARG GID=1000

LABEL "com.github.actions.name"="Unity - Builder"
LABEL "com.github.actions.description"="Build Unity projects for different platforms."
LABEL "com.github.actions.icon"="box"
Expand All @@ -14,15 +10,9 @@ LABEL "repository"="http://github.com/webbertakken/unity-actions"
LABEL "homepage"="http://github.com/webbertakken/unity-actions"
LABEL "maintainer"="Webber Takken <[email protected]>"

RUN bash -c 'mkdir -p /github/{home,workflow,workspace}' && chown $UID:$GID -R /github/
RUN getent group $GID || groupadd -g $GID $UNAME
RUN id -u $UID &>/dev/null || useradd -m -u $UID -g $GID -s /bin/bash -d /github/home $UNAME

ADD default-build-script /UnityBuilderAction
ADD steps /steps
RUN chmod -R +x /steps
ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

USER $UID:$GID
2 changes: 1 addition & 1 deletion action/index.js

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ async function action() {
} else {
// Build docker image
// TODO: No image required (instead use a version published to dockerhub for the action, supply credentials for github cloning)
const builtImage = await Docker.build({
path: actionFolder,
dockerfile,
baseImage,
uid: buildParameters.uid,
gid: buildParameters.gid,
});
const builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
await Docker.run(builtImage, { workspace, ...buildParameters });
}

Expand Down
6 changes: 1 addition & 5 deletions src/model/build-parameters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os from 'os';
import AndroidVersioning from './android-versioning';
import Input from './input';
import Platform from './platform';
Expand All @@ -21,13 +20,10 @@ class BuildParameters {
Input.androidVersionCode,
);

const { uid, gid } = os.userInfo();

return {
version: Input.unityVersion,
customImage: Input.customImage,
uid,
gid,

runnerTempPath: process.env.RUNNER_TEMP,
platform: Input.targetPlatform,
projectPath: Input.projectPath,
Expand Down
8 changes: 1 addition & 7 deletions src/model/docker.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import fs from 'fs';
import { exec } from '@actions/exec';
import ImageTag from './image-tag';

class Docker {
static async build(buildParameters, silent = false) {
const { path, dockerfile, baseImage, uid, gid } = buildParameters;
const { path, dockerfile, baseImage } = buildParameters;
const { version, platform } = baseImage;

const tag = new ImageTag({ repository: '', name: 'unity-builder', version, platform });
const command = `docker build ${path} \
--file ${dockerfile} \
--build-arg IMAGE=${baseImage} \
--build-arg UID=${uid} \
--build-arg GID=${gid} \
--tag ${tag}`;

await exec(command, undefined, { silent });
Expand Down Expand Up @@ -86,9 +83,6 @@ class Docker {
--volume "${workspace}":"/github/workspace" \
${image}`;

fs.mkdirSync(`${runnerTempPath}/_github_home`, { recursive: true });
fs.mkdirSync(`${runnerTempPath}/_github_workflow`, { recursive: true });

await exec(command, undefined, { silent });
}
}
Expand Down

0 comments on commit e6d3dae

Please sign in to comment.