60 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-07-25 17:09:22 -04:00
const core = require('@actions/core');
const fs = require('fs');
const path = require('path')
// Setup Docker
const Docker = require('dockerode');
var docker = new Docker({socketPath: '/var/run/docker.sock'});
try {
// Get inputs
var docker_image = core.getInput('containerImage');
var work_dir = core.getInput('directory');
2020-07-25 17:57:44 -04:00
if(work_dir)
{
process.chdir(work_dir);
}
2020-07-25 17:09:22 -04:00
// Pull docker image for building
console.log("Pulling build image...");
docker.pull(docker_image, function(err, stream)
{
docker.modem.followProgress(stream, onFinished, onProgress);
// Wait to run build until after pull complete
function onFinished(err, output)
{
console.log("Starting image...")
docker.run(docker_image, ['godot', '-d', '-s', '--path', '/project', 'addons/gut/gut_cmdln.gd'], process.stdout,
2020-07-25 17:09:22 -04:00
// Mount working directory to `/project`
{ HostConfig: { Binds: [ process.cwd() + ":/project" ] }},
2020-07-25 17:09:22 -04:00
function (err, data, container) {
2020-10-18 21:51:42 -04:00
console.log("DATA: " + String(data))
2020-07-25 17:09:22 -04:00
if(err)
{
core.setFailed(error.message);
2020-07-25 17:09:22 -04:00
}
console.log("Tests exited with status: " + data.StatusCode);
if( data.StatusCode != "0" )
{
core.setFailed("GUT tests failed!");
}
2020-07-25 17:09:22 -04:00
})
}
function onProgress(event) {}
});
} catch (error) {
core.setFailed(error.message);
}