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

record and report docker build duration seconds (#33)

This commit is contained in:
Aayush Shah 2024-11-19 02:28:40 -05:00 committed by GitHub
parent 7d2e9e7288
commit a6005ce994
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 4 deletions

View file

@ -61,7 +61,8 @@ async function reportBuildCompleted() {
// Report success to Blacksmith API
const requestOptions = {
docker_build_id: stateHelper.blacksmithDockerBuildId,
conclusion: 'successful'
conclusion: 'successful',
runtime_seconds: stateHelper.dockerBuildDurationSeconds
};
await postWithRetryToBlacksmithAPI(`/stickydisks/dockerbuilds/${stateHelper.blacksmithDockerBuildId}`, requestOptions, retryCondition);
@ -93,7 +94,8 @@ async function reportBuildFailed() {
// Report failure to Blacksmith API
const requestOptions = {
docker_build_id: stateHelper.blacksmithDockerBuildId,
conclusion: 'failed'
conclusion: 'failed',
runtime_seconds: stateHelper.dockerBuildDurationSeconds
};
await postWithRetryToBlacksmithAPI(`/stickydisks/dockerbuilds/${stateHelper.blacksmithDockerBuildId}`, requestOptions, retryCondition);
@ -566,6 +568,7 @@ actionsToolkit.run(
core.debug(`buildCmd.args: ${JSON.stringify(buildCmd.args)}`);
let err: Error | undefined;
const buildStartTime = Date.now();
await Exec.getExecOutput(buildCmd.command, buildCmd.args, {
ignoreReturnCode: true,
env: Object.assign({}, process.env, {
@ -577,6 +580,8 @@ actionsToolkit.run(
if (res.stderr.length > 0 && res.exitCode != 0) {
err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
}
const buildDurationSeconds = Math.round((Date.now() - buildStartTime) / 1000).toString();
stateHelper.setDockerBuildDurationSeconds(buildDurationSeconds);
});
const imageID = toolkit.buildxBuild.resolveImageID();