2
0
Fork 0
mirror of https://code.forgejo.org/docker/build-push-action.git synced 2025-08-17 17:20:53 +00:00
docker-build-push-action/src/state-helper.ts
Claude cc46a915dd refactor: complete removal of buildkit and sticky disk management
This commit completes the refactoring of build-push-action to focus solely on
Docker build reporting and metrics, with all infrastructure management moved
to the separate setup-docker-builder action.

Changes:
- Remove all setupOnly references from context.ts, main.ts, and state-helper.ts
- Rename startBlacksmithBuilder to reportBuildMetrics to better reflect its purpose
- Remove exposeId from all function signatures and state management
- Remove sticky disk commit logic from reporter.ts
- Update tests to match new function names and signatures
- Clean up unused imports and fix linting issues

The action now assumes that a Docker builder has already been configured
(either via setup-docker-builder or existing setup) and focuses only on:
- Running Docker builds with the configured builder
- Reporting build metrics and status to Blacksmith API
- Managing build outputs and metadata

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 14:25:57 -04:00

60 lines
2.5 KiB
TypeScript

import * as core from '@actions/core';
import {Inputs, sanitizeInputs} from './context';
export const tmpDir = process.env['STATE_tmpDir'] || '';
export const inputs = process.env['STATE_inputs'] ? JSON.parse(process.env['STATE_inputs']) : undefined;
export const buildRef = process.env['STATE_buildRef'] || '';
export const isSummarySupported = !!process.env['STATE_isSummarySupported'];
export const blacksmithDockerBuildId = process.env['STATE_blacksmithDockerBuildId'] || '';
export const blacksmithClientKey = process.env['STATE_blacksmithClientKey'] || '';
export const blacksmithClientCaCertificate = process.env['STATE_blacksmithClientCaCertificate'] || '';
export const blacksmithRootCaCertificate = process.env['STATE_blacksmithRootCaCertificate'] || '';
export const dockerBuildStatus = process.env['STATE_dockerBuildStatus'] || '';
export const blacksmithBuilderLaunchTime = process.env['STATE_blacksmithBuilderLaunchTime'] || '';
export const dockerBuildDurationSeconds = process.env['STATE_dockerBuildDurationSeconds'] || '';
export function setTmpDir(tmpDir: string) {
core.saveState('tmpDir', tmpDir);
}
export function setInputs(inputs: Inputs) {
core.saveState('inputs', JSON.stringify(sanitizeInputs(inputs)));
}
export function setBuildRef(buildRef: string) {
core.saveState('buildRef', buildRef);
}
export function setSummarySupported() {
core.saveState('isSummarySupported', 'true');
}
export function setBlacksmithDockerBuildId(blacksmithDockerBuildId: string) {
core.saveState('blacksmithDockerBuildId', blacksmithDockerBuildId);
}
// setBlacksmithBuilderLaunchTime sets the time (in seconds) it took to launch the Blacksmith builder
export function setBlacksmithBuilderLaunchTime(blacksmithBuilderLaunchTime: string) {
core.saveState('blacksmithBuilderLaunchTime', blacksmithBuilderLaunchTime);
}
export function setBlacksmithClientKey(blacksmithClientKey: string) {
core.saveState('blacksmithClientKey', blacksmithClientKey);
}
export function setBlacksmithClientCaCertificate(blacksmithClientCaCertificate: string) {
core.saveState('blacksmithClientCaCertificate', blacksmithClientCaCertificate);
}
export function setBlacksmithRootCaCertificate(blacksmithRootCaCertificate: string) {
core.saveState('blacksmithRootCaCertificate', blacksmithRootCaCertificate);
}
export function setDockerBuildStatus(dockerBuildStatus: string) {
core.saveState('dockerBuildStatus', dockerBuildStatus);
}
export function setDockerBuildDurationSeconds(dockerBuildDurationSeconds: string) {
core.saveState('dockerBuildDurationSeconds', dockerBuildDurationSeconds);
}