diff --git a/Dockerfile b/Dockerfile index d8fea678..fa5af25b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,8 @@ -FROM gableroux/unity3d:2019.2.11f1-webgl +ARG IMAGE_REPOSITORY +ARG IMAGE_NAME +ARG IMAGE_VERSION + +FROM $IMAGE_REPOSITORY/$IMAGE_NAME:$IMAGE_VERSION LABEL "com.github.actions.name"="Unity - Builder" LABEL "com.github.actions.description"="Build Unity projects for different platforms." @@ -9,9 +13,9 @@ LABEL "repository"="http://github.com/webbertakken/unity-actions" LABEL "homepage"="http://github.com/webbertakken/unity-actions" LABEL "maintainer"="Webber Takken " -ENV BUILD_TARGET=WebGL - ADD default-build-script /UnityBuilderAction ADD entrypoint.sh /entrypoint.sh + RUN chmod +x /entrypoint.sh + ENTRYPOINT ["/entrypoint.sh"] diff --git a/dist/index.js b/dist/index.js index f7a2843e..c17a16a1 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/run-unity-builder.sh b/dist/run-unity-builder.sh index deba43bf..47481482 100644 --- a/dist/run-unity-builder.sh +++ b/dist/run-unity-builder.sh @@ -4,12 +4,13 @@ # Input variables # -PROJECT_PATH=$1 -UNITY_VERSION="2019.2.11f1" -BUILD_TARGET=$2 -BUILD_NAME=$3 -BUILDS_PATH=$4 -BUILD_METHOD=$5 +IMAGE_UNITY_VERSION=$1 +IMAGE_TARGET_PLATFORM=$2 +PROJECT_PATH=$3 +TARGET_PLATFORM=$4 +BUILD_NAME=$5 +BUILDS_PATH=$6 +BUILD_METHOD=$7 # # Default variables @@ -42,9 +43,9 @@ BUILD_METHOD=$5 # ACTION_ROOT=$(dirname $(dirname $(readlink -fm "$0"))) -DOCKER_IMAGE_TAG=webber-unity:$UNITY_VERSION-$BUILD_TARGET +DOCKER_IMAGE_TAG=unity-builder:$UNITY_VERSION-$TARGET_PLATFORM -# TODO - Remove debug statements below +# TODO - Remove debug statements (after it is proven to work) echo "Listing ACTION_ROOT" ls $ACTION_ROOT @@ -60,9 +61,12 @@ echo "" # Build image # -echo "Building docker images for $BUILD_TARGET" +echo "Building docker image for $UNITY_VERSION-$TARGET_PLATFORM" docker build $GITHUB_WORKSPACE \ --file $ACTION_ROOT/Dockerfile \ + --build-arg IMAGE_REPOSITORY=gableroux \ + --build-arg IMAGE_NAME=unity3d \ + --build-arg IMAGE_VERSION=$IMAGE_UNITY_VERSION-$IMAGE_TARGET_PLATFORM \ --tag $DOCKER_IMAGE_TAG # @@ -73,7 +77,7 @@ docker run \ --workdir /github/workspace \ --rm \ --env PROJECT_PATH \ - --env BUILD_TARGET \ + --env BUILD_TARGET=$TARGET_PLATFORM \ --env BUILD_NAME \ --env BUILDS_PATH \ --env BUILD_METHOD \ diff --git a/src/index.js b/src/index.js index 44c15b80..e276b9ca 100644 --- a/src/index.js +++ b/src/index.js @@ -10,16 +10,29 @@ async function action() { // Input variables specified in workflows using "with" prop. const projectPath = core.getInput('projectPath', { default: './' }); - const buildTarget = core.getInput('buildTarget', { default: 'WebGL' }); + const targetPlatform = core.getInput('targetPlatform', { default: 'WebGL' }); + const unityVersion = core.getInput('unityVersion', { default: '2019.2.11f1' }); const buildName = core.getInput('buildName', { default: 'TestBuild' }); const buildsPath = core.getInput('buildsPath', { default: 'build' }); const buildMethod = core.getInput('buildMethod', { default: '' }); + // Determine image + const IMAGE_UNITY_VERSION = unityVersion; + const IMAGE_TARGET_PLATFORM = targetPlatform.toLowerCase(); + // Run appropriate docker image with given args const bootstrapper = path.join(__dirname, 'run-unity-builder.sh'); await exec(`ls ${bootstrapper}`); await exec(`chmod +x ${bootstrapper}`); - await exec(bootstrapper, [projectPath, buildTarget, buildName, buildsPath, buildMethod]); + await exec(bootstrapper, [ + IMAGE_UNITY_VERSION, + IMAGE_TARGET_PLATFORM, + projectPath, + targetPlatform, + buildName, + buildsPath, + buildMethod, + ]); } action().catch(error => { diff --git a/src/run-unity-builder.sh b/src/run-unity-builder.sh index deba43bf..47481482 100644 --- a/src/run-unity-builder.sh +++ b/src/run-unity-builder.sh @@ -4,12 +4,13 @@ # Input variables # -PROJECT_PATH=$1 -UNITY_VERSION="2019.2.11f1" -BUILD_TARGET=$2 -BUILD_NAME=$3 -BUILDS_PATH=$4 -BUILD_METHOD=$5 +IMAGE_UNITY_VERSION=$1 +IMAGE_TARGET_PLATFORM=$2 +PROJECT_PATH=$3 +TARGET_PLATFORM=$4 +BUILD_NAME=$5 +BUILDS_PATH=$6 +BUILD_METHOD=$7 # # Default variables @@ -42,9 +43,9 @@ BUILD_METHOD=$5 # ACTION_ROOT=$(dirname $(dirname $(readlink -fm "$0"))) -DOCKER_IMAGE_TAG=webber-unity:$UNITY_VERSION-$BUILD_TARGET +DOCKER_IMAGE_TAG=unity-builder:$UNITY_VERSION-$TARGET_PLATFORM -# TODO - Remove debug statements below +# TODO - Remove debug statements (after it is proven to work) echo "Listing ACTION_ROOT" ls $ACTION_ROOT @@ -60,9 +61,12 @@ echo "" # Build image # -echo "Building docker images for $BUILD_TARGET" +echo "Building docker image for $UNITY_VERSION-$TARGET_PLATFORM" docker build $GITHUB_WORKSPACE \ --file $ACTION_ROOT/Dockerfile \ + --build-arg IMAGE_REPOSITORY=gableroux \ + --build-arg IMAGE_NAME=unity3d \ + --build-arg IMAGE_VERSION=$IMAGE_UNITY_VERSION-$IMAGE_TARGET_PLATFORM \ --tag $DOCKER_IMAGE_TAG # @@ -73,7 +77,7 @@ docker run \ --workdir /github/workspace \ --rm \ --env PROJECT_PATH \ - --env BUILD_TARGET \ + --env BUILD_TARGET=$TARGET_PLATFORM \ --env BUILD_NAME \ --env BUILDS_PATH \ --env BUILD_METHOD \