1
0
Fork 0
mirror of https://github.com/docker/build-push-action.git synced 2025-06-08 05:31:51 +02:00

Fix and cleanup of v2 setup actions

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-08-16 04:10:09 +02:00
parent 3f08c86128
commit e9cb922263
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
19 changed files with 66 additions and 3827 deletions

View file

@ -1,4 +1,4 @@
import * as actionsExec from '@actions/exec';
import * as aexec from '@actions/exec';
import {ExecOptions} from '@actions/exec';
export interface ExecResult {
@ -24,7 +24,7 @@ export const exec = async (command: string, args: string[] = [], silent: boolean
}
};
const returnCode: number = await actionsExec.exec(command, args, options);
const returnCode: number = await aexec.exec(command, args, options);
return {
success: returnCode === 0,

View file

@ -1,9 +1,10 @@
import * as os from 'os';
import * as path from 'path';
import * as buildx from './buildx';
import * as exec from './exec';
import * as mexec from './exec';
import * as stateHelper from './state-helper';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
async function run(): Promise<void> {
try {
@ -25,7 +26,7 @@ async function run(): Promise<void> {
}
core.info('📣 Buildx info');
await exec.exec('docker', ['buildx', 'version'], false);
await exec.exec('docker', ['buildx', 'version']);
const builderName: string = `builder-${(await buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`;
core.setOutput('name', builderName);
@ -40,14 +41,14 @@ async function run(): Promise<void> {
createArgs.push('--use');
}
await exec.exec('docker', createArgs, false);
await exec.exec('docker', createArgs);
core.info('🏃 Booting builder...');
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap'], false);
await exec.exec('docker', ['buildx', 'inspect', '--bootstrap']);
if (bxInstall) {
core.info('🤝 Setting buildx as default builder...');
await exec.exec('docker', ['buildx', 'install'], false);
await exec.exec('docker', ['buildx', 'install']);
}
core.info('🛒 Extracting available platforms...');
@ -60,12 +61,14 @@ async function run(): Promise<void> {
}
async function cleanup(): Promise<void> {
try {
core.info('🚿 Removing builder instance...');
await exec.exec('docker', ['buildx', 'rm', `${process.env.STATE_builderName}`], false);
} catch (error) {
core.warning(error.message);
if (stateHelper.builderName.length == 0) {
return;
}
await mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => {
if (res.stderr != '' && !res.success) {
core.warning(res.stderr);
}
});
}
if (!stateHelper.IsPost) {

View file

@ -1,7 +1,7 @@
import * as core from '@actions/core';
export const IsPost = !!process.env['STATE_isPost'];
export const builderName = !!process.env['STATE_builderName'];
export const builderName = process.env['STATE_builderName'] || '';
export function setBuilderName(builderName: string) {
core.saveState('builderName', builderName);