From 302bd4c880904e009c22d37693fb390d23966199 Mon Sep 17 00:00:00 2001 From: Webber Date: Tue, 17 Dec 2019 00:53:39 +0100 Subject: [PATCH] Add initial script --- src/index.js | 48 ++++++++++++++++++++++++++++++++++++++++ src/run-unity-builder.sh | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/index.js create mode 100644 src/run-unity-builder.sh diff --git a/src/index.js b/src/index.js new file mode 100644 index 00000000..d0f80c8d --- /dev/null +++ b/src/index.js @@ -0,0 +1,48 @@ +const core = require('@actions/core'); +const path = require('path'); +const { exec } = require('@actions/exec'); + +async function action() { + // Path to the project to open with Unity + const projectPath = core.getInput('projectPath', { + required: false, + default: './', + }); + + // Target platform for the build + const buildTarget = core.getInput('buildTarget', { + required: false, + default: 'WebGL', + }); + + // Name of the build + const buildName = core.getInput('buildName', { + required: false, + default: 'TestBuild', + }); + + // Path where build will be stored + const buildsPath = core.getInput('buildsPath', { + required: false, + default: 'build', + }); + + // Method to execute within unity. Must be static + const buildMethod = core.getInput('buildMethod', { + required: false, + default: '', + }); + + // Run appropriate docker image with given args + await exec(path.join(__dirname, 'run-unity-builder.sh'), [ + projectPath, + buildTarget, + buildName, + buildsPath, + buildMethod, + ]); +} + +action().catch(error => { + core.setFailed(error.message); +}); diff --git a/src/run-unity-builder.sh b/src/run-unity-builder.sh new file mode 100644 index 00000000..d4cc9f36 --- /dev/null +++ b/src/run-unity-builder.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env sh + +PROJECT_PATH=$1 +BUILD_TARGET=$2 +BUILD_NAME=$3 +BUILDS_PATH=$4 +BUILD_METHOD=$5 + +DOCKER_IMAGE_TAG=unity-builder-image + +echo "Running docker container with specific tag" + +docker build \ + --file ../Dockerfile \ + --tag DOCKER_IMAGE_TAG \ + ../ + +docker run \ + --workdir /github/workspace \ + --rm \ + --env PROJECT_PATH \ + --env BUILD_TARGET \ + --env BUILD_NAME \ + --env BUILDS_PATH \ + --env BUILD_METHOD \ + --env HOME \ + --env GITHUB_REF \ + --env GITHUB_SHA \ + --env GITHUB_REPOSITORY \ + --env GITHUB_ACTOR \ + --env GITHUB_WORKFLOW \ + --env GITHUB_HEAD_REF \ + --env GITHUB_BASE_REF \ + --env GITHUB_EVENT_NAME \ + --env GITHUB_WORKSPACE \ + --env GITHUB_ACTION \ + --env GITHUB_EVENT_PATH \ + --env RUNNER_OS \ + --env RUNNER_TOOL_CACHE \ + --env RUNNER_TEMP \ + --env RUNNER_WORKSPACE \ + --volume "/var/run/docker.sock":"/var/run/docker.sock" \ + --volume "/home/runner/work/_temp/_github_home":"/github/home" \ + --volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \ + --volume "${PWD}":"/github/workspace" \ + DOCKER_IMAGE_TAG