mirror of
https://github.com/docker/setup-compose-action.git
synced 2025-12-31 15:41:19 +01:00
initial version
This commit is contained in:
13
src/context.ts
Normal file
13
src/context.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export interface Inputs {
|
||||
version: string;
|
||||
cacheBinary: boolean;
|
||||
}
|
||||
|
||||
export async function getInputs(): Promise<Inputs> {
|
||||
return {
|
||||
version: core.getInput('version'),
|
||||
cacheBinary: core.getBooleanInput('cache-binary')
|
||||
};
|
||||
}
|
||||
46
src/main.ts
Normal file
46
src/main.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||
|
||||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||
|
||||
import * as context from './context';
|
||||
|
||||
actionsToolkit.run(
|
||||
// main
|
||||
async () => {
|
||||
const inputs: context.Inputs = await context.getInputs();
|
||||
|
||||
const toolkit = new Toolkit();
|
||||
const standalone = await toolkit.compose.isStandalone();
|
||||
|
||||
await core.group(`Docker info`, async () => {
|
||||
try {
|
||||
await Docker.printVersion();
|
||||
await Docker.printInfo();
|
||||
} catch (e) {
|
||||
core.info(e.message);
|
||||
}
|
||||
});
|
||||
|
||||
let toolPath;
|
||||
if (!(await toolkit.compose.isAvailable()) || inputs.version) {
|
||||
await core.group(`Download compose from GitHub Releases`, async () => {
|
||||
toolPath = await toolkit.composeInstall.download(inputs.version || 'latest', !inputs.cacheBinary);
|
||||
});
|
||||
}
|
||||
if (toolPath) {
|
||||
await core.group(`Install compose`, async () => {
|
||||
if (standalone) {
|
||||
await toolkit.composeInstall.installStandalone(toolPath);
|
||||
} else {
|
||||
await toolkit.composeInstall.installPlugin(toolPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await core.group(`Compose version`, async () => {
|
||||
await toolkit.compose.printVersion();
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user