2020-10-25 02:25:23 +01:00
|
|
|
import {getInputs, Inputs} from './context';
|
|
|
|
import * as github from './github';
|
|
|
|
import {Meta} from './meta';
|
|
|
|
import * as core from '@actions/core';
|
|
|
|
import {Context} from '@actions/github/lib/context';
|
|
|
|
import {ReposGetResponseData} from '@octokit/types';
|
|
|
|
|
|
|
|
async function run() {
|
|
|
|
try {
|
|
|
|
const inputs: Inputs = await getInputs();
|
|
|
|
if (inputs.images.length == 0) {
|
|
|
|
throw new Error(`images input required`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const context: Context = github.context();
|
|
|
|
const repo: ReposGetResponseData = await github.repo(inputs.githubToken);
|
|
|
|
core.startGroup(`Context info`);
|
|
|
|
core.info(`eventName: ${context.eventName}`);
|
|
|
|
core.info(`sha: ${context.sha}`);
|
|
|
|
core.info(`ref: ${context.ref}`);
|
|
|
|
core.info(`workflow: ${context.workflow}`);
|
|
|
|
core.info(`action: ${context.action}`);
|
|
|
|
core.info(`actor: ${context.actor}`);
|
|
|
|
core.info(`runNumber: ${context.runNumber}`);
|
|
|
|
core.info(`runId: ${context.runId}`);
|
|
|
|
core.endGroup();
|
|
|
|
|
|
|
|
const meta: Meta = new Meta(inputs, context, repo);
|
|
|
|
|
2020-10-25 02:40:42 +01:00
|
|
|
const version: string | undefined = meta.version();
|
|
|
|
core.startGroup(`Docker image version`);
|
|
|
|
core.info(`${version}`);
|
|
|
|
core.endGroup();
|
2020-10-25 15:13:43 +01:00
|
|
|
core.setOutput('version', version || '');
|
2020-10-25 02:40:42 +01:00
|
|
|
|
2020-10-25 02:25:23 +01:00
|
|
|
const tags: Array<string> = meta.tags();
|
2020-10-25 02:40:42 +01:00
|
|
|
core.startGroup(`Docker tags`);
|
2020-10-25 03:21:46 +01:00
|
|
|
for (let tag of tags) {
|
|
|
|
core.info(tag);
|
|
|
|
}
|
2020-10-25 02:25:23 +01:00
|
|
|
core.endGroup();
|
|
|
|
core.setOutput('tags', tags.join(inputs.sepTags));
|
|
|
|
|
|
|
|
const labels: Array<string> = meta.labels();
|
2020-10-25 02:40:42 +01:00
|
|
|
core.startGroup(`Docker labels`);
|
2020-10-25 03:21:46 +01:00
|
|
|
for (let label of labels) {
|
|
|
|
core.info(label);
|
|
|
|
}
|
2020-10-25 02:25:23 +01:00
|
|
|
core.endGroup();
|
|
|
|
core.setOutput('labels', labels.join(inputs.sepTags));
|
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|