mirror of
https://github.com/docker/build-push-action.git
synced 2026-06-28 09:27:42 +00:00
35 lines
986 B
TypeScript
35 lines
986 B
TypeScript
import * as core from '@actions/core';
|
|
|
|
import {Inputs} 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 function setTmpDir(tmpDir: string) {
|
|
core.saveState('tmpDir', tmpDir);
|
|
}
|
|
|
|
export function setInputs(inputs: Inputs) {
|
|
const newInputs = {};
|
|
for (const key of Object.keys(inputs)) {
|
|
if (key === 'github-token') {
|
|
continue;
|
|
}
|
|
const value: string | string[] | boolean = inputs[key];
|
|
if (typeof value === 'boolean' && value === false) {
|
|
continue;
|
|
} else if (Array.isArray(value) && value.length === 0) {
|
|
continue;
|
|
} else if (!value) {
|
|
continue;
|
|
}
|
|
newInputs[key] = value;
|
|
}
|
|
core.saveState('inputs', JSON.stringify(newInputs));
|
|
}
|
|
|
|
export function setBuildRef(buildRef: string) {
|
|
core.saveState('buildRef', buildRef);
|
|
}
|