mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-12 12:38:09 +00:00
Improve stateHelper
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
e53a3da260
commit
c3b8f61f90
21
setup-buildx/dist/index.js
generated
vendored
21
setup-buildx/dist/index.js
generated
vendored
@ -2163,7 +2163,6 @@ exports.debug = debug; // for test
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// From https://github.com/actions/checkout/blob/master/src/state-helper.ts
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
@ -2184,16 +2183,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.IsPost = void 0;
|
exports.setBuilderName = exports.builderName = exports.IsPost = void 0;
|
||||||
const coreCommand = __importStar(__webpack_require__(804));
|
const core = __importStar(__webpack_require__(470));
|
||||||
/**
|
|
||||||
* Indicates whether the POST action is running
|
|
||||||
*/
|
|
||||||
exports.IsPost = !!process.env['STATE_isPost'];
|
exports.IsPost = !!process.env['STATE_isPost'];
|
||||||
// Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
|
exports.builderName = !!process.env['STATE_builderName'];
|
||||||
// This is necessary since we don't have a separate entry point.
|
function setBuilderName(builderName) {
|
||||||
|
core.saveState('builderName', builderName);
|
||||||
|
}
|
||||||
|
exports.setBuilderName = setBuilderName;
|
||||||
if (!exports.IsPost) {
|
if (!exports.IsPost) {
|
||||||
coreCommand.issueCommand('save-state', { name: 'isPost' }, 'true');
|
core.saveState('isPost', 'true');
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=state-helper.js.map
|
//# sourceMappingURL=state-helper.js.map
|
||||||
|
|
||||||
@ -2502,8 +2501,8 @@ function run() {
|
|||||||
core.info('📣 Buildx info');
|
core.info('📣 Buildx info');
|
||||||
yield exec.exec('docker', ['buildx', 'version'], false);
|
yield exec.exec('docker', ['buildx', 'version'], false);
|
||||||
const builderName = `builder-${(yield buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`;
|
const builderName = `builder-${(yield buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`;
|
||||||
core.saveState('builderName', builderName);
|
|
||||||
core.setOutput('name', builderName);
|
core.setOutput('name', builderName);
|
||||||
|
stateHelper.setBuilderName(builderName);
|
||||||
core.info('🔨 Creating a new builder instance...');
|
core.info('🔨 Creating a new builder instance...');
|
||||||
let createArgs = ['buildx', 'create', '--name', builderName, '--driver', driver];
|
let createArgs = ['buildx', 'create', '--name', builderName, '--driver', driver];
|
||||||
if (driverOpt) {
|
if (driverOpt) {
|
||||||
@ -2538,11 +2537,9 @@ function cleanup() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Main
|
|
||||||
if (!stateHelper.IsPost) {
|
if (!stateHelper.IsPost) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
// Post
|
|
||||||
else {
|
else {
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ async function run(): Promise<void> {
|
|||||||
await exec.exec('docker', ['buildx', 'version'], false);
|
await exec.exec('docker', ['buildx', 'version'], false);
|
||||||
|
|
||||||
const builderName: string = `builder-${(await buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`;
|
const builderName: string = `builder-${(await buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`;
|
||||||
core.saveState('builderName', builderName);
|
|
||||||
core.setOutput('name', builderName);
|
core.setOutput('name', builderName);
|
||||||
|
stateHelper.setBuilderName(builderName);
|
||||||
|
|
||||||
core.info('🔨 Creating a new builder instance...');
|
core.info('🔨 Creating a new builder instance...');
|
||||||
let createArgs: Array<string> = ['buildx', 'create', '--name', builderName, '--driver', driver];
|
let createArgs: Array<string> = ['buildx', 'create', '--name', builderName, '--driver', driver];
|
||||||
@ -66,11 +66,8 @@ async function cleanup(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main
|
|
||||||
if (!stateHelper.IsPost) {
|
if (!stateHelper.IsPost) {
|
||||||
run();
|
run();
|
||||||
}
|
} else {
|
||||||
// Post
|
|
||||||
else {
|
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
// From https://github.com/actions/checkout/blob/master/src/state-helper.ts
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import * as coreCommand from '@actions/core/lib/command';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the POST action is running
|
|
||||||
*/
|
|
||||||
export const IsPost = !!process.env['STATE_isPost'];
|
export const IsPost = !!process.env['STATE_isPost'];
|
||||||
|
export const builderName = !!process.env['STATE_builderName'];
|
||||||
|
|
||||||
// Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
|
export function setBuilderName(builderName: string) {
|
||||||
// This is necessary since we don't have a separate entry point.
|
core.saveState('builderName', builderName);
|
||||||
if (!IsPost) {
|
}
|
||||||
coreCommand.issueCommand('save-state', {name: 'isPost'}, 'true');
|
|
||||||
|
if (!IsPost) {
|
||||||
|
core.saveState('isPost', 'true');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user