Run docker from javascript

This commit is contained in:
Webber
2019-12-22 15:05:15 +01:00
committed by Webber Takken
parent 9a639e97e3
commit 2ab738c083
19 changed files with 1013 additions and 181 deletions

View File

@@ -1,38 +1,26 @@
import Action from './model/action';
import Docker from './model/docker';
import ImageTag from './model/image';
import Input from './model/input';
const core = require('@actions/core');
const path = require('path');
const { exec } = require('@actions/exec');
async function action() {
// Explicitly notify about platform support
if (process.platform !== 'linux') {
throw new Error('Currently only Linux-based platforms are supported');
}
Action.checkCompatibility();
// Input variables specified in workflows using "with" prop.
const projectPath = core.getInput('projectPath', { default: './' });
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, [
IMAGE_UNITY_VERSION,
IMAGE_TARGET_PLATFORM,
projectPath,
const {
unityVersion,
targetPlatform,
projectPath,
buildName,
buildsPath,
buildMethod,
]);
} = Input.getFromUser();
const { dockerfile, workspace } = Action;
const baseImage = new ImageTag({ unityVersion, targetPlatform });
const builtImage = await Docker.build({ path: workspace, dockerfile, image: baseImage });
await Docker.run(builtImage, { projectPath, buildName, buildsPath, buildMethod });
}
action().catch(error => {