mirror of
https://code.forgejo.org/docker/build-push-action.git
synced 2025-08-11 17:10:54 +00:00
Fix and cleanup of v2 setup actions
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
3f08c86128
commit
e9cb922263
19 changed files with 66 additions and 3827 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue