mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-04-23 08:26:38 +02:00
Add config-inline
input
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
ee7ac3140a
commit
34e94a5fed
13 changed files with 4751 additions and 16 deletions
|
@ -19,6 +19,28 @@ export type Builder = {
|
|||
node_platforms?: string;
|
||||
};
|
||||
|
||||
export async function getConfigInline(s: string): Promise<string> {
|
||||
return getConfig(s, false);
|
||||
}
|
||||
|
||||
export async function getConfigFile(s: string): Promise<string> {
|
||||
return getConfig(s, true);
|
||||
}
|
||||
|
||||
export async function getConfig(s: string, file: boolean): Promise<string> {
|
||||
if (file) {
|
||||
if (!fs.existsSync(s)) {
|
||||
throw new Error(`config file ${s} not found`);
|
||||
}
|
||||
s = fs.readFileSync(s, {encoding: 'utf-8'});
|
||||
}
|
||||
const configFile = context.tmpNameSync({
|
||||
tmpdir: context.tmpDir()
|
||||
});
|
||||
fs.writeFileSync(configFile, s);
|
||||
return configFile;
|
||||
}
|
||||
|
||||
export async function isAvailable(): Promise<Boolean> {
|
||||
return await exec
|
||||
.getExecOutput('docker', ['buildx'], {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import path from 'path';
|
||||
import * as tmp from 'tmp';
|
||||
import * as core from '@actions/core';
|
||||
import {issueCommand} from '@actions/core/lib/command';
|
||||
|
||||
|
@ -15,6 +16,10 @@ export function tmpDir(): string {
|
|||
return _tmpDir;
|
||||
}
|
||||
|
||||
export function tmpNameSync(options?: tmp.TmpNameOptions): string {
|
||||
return tmp.tmpNameSync(options);
|
||||
}
|
||||
|
||||
export interface Inputs {
|
||||
version: string;
|
||||
driver: string;
|
||||
|
@ -24,6 +29,7 @@ export interface Inputs {
|
|||
use: boolean;
|
||||
endpoint: string;
|
||||
config: string;
|
||||
configInline: string;
|
||||
}
|
||||
|
||||
export async function getInputs(): Promise<Inputs> {
|
||||
|
@ -35,7 +41,8 @@ export async function getInputs(): Promise<Inputs> {
|
|||
install: core.getBooleanInput('install'),
|
||||
use: core.getBooleanInput('use'),
|
||||
endpoint: core.getInput('endpoint'),
|
||||
config: core.getInput('config')
|
||||
config: core.getInput('config'),
|
||||
configInline: core.getInput('config-inline')
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,9 @@ async function run(): Promise<void> {
|
|||
createArgs.push(inputs.endpoint);
|
||||
}
|
||||
if (inputs.config) {
|
||||
createArgs.push('--config', inputs.config);
|
||||
createArgs.push('--config', await buildx.getConfigFile(inputs.config));
|
||||
} else if (inputs.configInline) {
|
||||
createArgs.push('--config', await buildx.getConfigInline(inputs.configInline));
|
||||
}
|
||||
await exec.exec('docker', createArgs);
|
||||
core.endGroup();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue