Set build args for container

This commit is contained in:
Webber 2019-12-21 13:56:00 +01:00 committed by Webber Takken
parent dccdec9d3b
commit 454ff6054c
5 changed files with 50 additions and 25 deletions

View File

@ -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.name"="Unity - Builder"
LABEL "com.github.actions.description"="Build Unity projects for different platforms." 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 "homepage"="http://github.com/webbertakken/unity-actions"
LABEL "maintainer"="Webber Takken <webber@takken.io>" LABEL "maintainer"="Webber Takken <webber@takken.io>"
ENV BUILD_TARGET=WebGL
ADD default-build-script /UnityBuilderAction ADD default-build-script /UnityBuilderAction
ADD entrypoint.sh /entrypoint.sh ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]

BIN
dist/index.js vendored

Binary file not shown.

View File

@ -4,12 +4,13 @@
# Input variables # Input variables
# #
PROJECT_PATH=$1 IMAGE_UNITY_VERSION=$1
UNITY_VERSION="2019.2.11f1" IMAGE_TARGET_PLATFORM=$2
BUILD_TARGET=$2 PROJECT_PATH=$3
BUILD_NAME=$3 TARGET_PLATFORM=$4
BUILDS_PATH=$4 BUILD_NAME=$5
BUILD_METHOD=$5 BUILDS_PATH=$6
BUILD_METHOD=$7
# #
# Default variables # Default variables
@ -42,9 +43,9 @@ BUILD_METHOD=$5
# #
ACTION_ROOT=$(dirname $(dirname $(readlink -fm "$0"))) 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" echo "Listing ACTION_ROOT"
ls $ACTION_ROOT ls $ACTION_ROOT
@ -60,9 +61,12 @@ echo ""
# Build image # Build image
# #
echo "Building docker images for $BUILD_TARGET" echo "Building docker image for $UNITY_VERSION-$TARGET_PLATFORM"
docker build $GITHUB_WORKSPACE \ docker build $GITHUB_WORKSPACE \
--file $ACTION_ROOT/Dockerfile \ --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 --tag $DOCKER_IMAGE_TAG
# #
@ -73,7 +77,7 @@ docker run \
--workdir /github/workspace \ --workdir /github/workspace \
--rm \ --rm \
--env PROJECT_PATH \ --env PROJECT_PATH \
--env BUILD_TARGET \ --env BUILD_TARGET=$TARGET_PLATFORM \
--env BUILD_NAME \ --env BUILD_NAME \
--env BUILDS_PATH \ --env BUILDS_PATH \
--env BUILD_METHOD \ --env BUILD_METHOD \

View File

@ -10,16 +10,29 @@ async function action() {
// Input variables specified in workflows using "with" prop. // Input variables specified in workflows using "with" prop.
const projectPath = core.getInput('projectPath', { default: './' }); 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 buildName = core.getInput('buildName', { default: 'TestBuild' });
const buildsPath = core.getInput('buildsPath', { default: 'build' }); const buildsPath = core.getInput('buildsPath', { default: 'build' });
const buildMethod = core.getInput('buildMethod', { default: '' }); 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 // Run appropriate docker image with given args
const bootstrapper = path.join(__dirname, 'run-unity-builder.sh'); const bootstrapper = path.join(__dirname, 'run-unity-builder.sh');
await exec(`ls ${bootstrapper}`); await exec(`ls ${bootstrapper}`);
await exec(`chmod +x ${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 => { action().catch(error => {

View File

@ -4,12 +4,13 @@
# Input variables # Input variables
# #
PROJECT_PATH=$1 IMAGE_UNITY_VERSION=$1
UNITY_VERSION="2019.2.11f1" IMAGE_TARGET_PLATFORM=$2
BUILD_TARGET=$2 PROJECT_PATH=$3
BUILD_NAME=$3 TARGET_PLATFORM=$4
BUILDS_PATH=$4 BUILD_NAME=$5
BUILD_METHOD=$5 BUILDS_PATH=$6
BUILD_METHOD=$7
# #
# Default variables # Default variables
@ -42,9 +43,9 @@ BUILD_METHOD=$5
# #
ACTION_ROOT=$(dirname $(dirname $(readlink -fm "$0"))) 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" echo "Listing ACTION_ROOT"
ls $ACTION_ROOT ls $ACTION_ROOT
@ -60,9 +61,12 @@ echo ""
# Build image # Build image
# #
echo "Building docker images for $BUILD_TARGET" echo "Building docker image for $UNITY_VERSION-$TARGET_PLATFORM"
docker build $GITHUB_WORKSPACE \ docker build $GITHUB_WORKSPACE \
--file $ACTION_ROOT/Dockerfile \ --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 --tag $DOCKER_IMAGE_TAG
# #
@ -73,7 +77,7 @@ docker run \
--workdir /github/workspace \ --workdir /github/workspace \
--rm \ --rm \
--env PROJECT_PATH \ --env PROJECT_PATH \
--env BUILD_TARGET \ --env BUILD_TARGET=$TARGET_PLATFORM \
--env BUILD_NAME \ --env BUILD_NAME \
--env BUILDS_PATH \ --env BUILDS_PATH \
--env BUILD_METHOD \ --env BUILD_METHOD \