unity-builder/src/index.ts
Webber Takken 4fde4e47b6
Refactor action to typescript (#226)
* Refactor to typescript (config part)

* Refactor to typescript (convert extensions, minor fixes)

* Refactor to typescript (move from `action` to `dist`)

* Re-enable integrity-check for dist index.js

* Fix all tests and lints

* fix parsing major versions

* Test patch level to be digits only

* debug

* debug

* uncache

* manual compile

* debug

* debug

* Debug

* Build lib - doh

* remove diff check

* Make kubernetes workflow manual

* Properly generate 3 digit for simple major tags

* Remove ts-ignore

* re-enable cache
2021-03-14 00:44:01 +01:00

31 lines
1.0 KiB
TypeScript

import * as core from '@actions/core';
import { Action, BuildParameters, Cache, Docker, ImageTag, Kubernetes, Output } from './model';
async function run() {
try {
Action.checkCompatibility();
Cache.verify();
const { dockerfile, workspace, actionFolder } = Action;
const buildParameters = await BuildParameters.create();
const baseImage = new ImageTag(buildParameters);
if (buildParameters.kubeConfig) {
core.info('Building with Kubernetes');
await Kubernetes.runBuildJob(buildParameters, baseImage);
} else {
// Build docker image
// TODO: No image required (instead use a version published to dockerhub for the action, supply credentials for github cloning)
const builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
await Docker.run(builtImage, { workspace, ...buildParameters });
}
// Set output
await Output.setBuildVersion(buildParameters.buildVersion);
} catch (error) {
core.setFailed(error.message);
}
}
run();