Compare commits
3 Commits
6a855842ef
...
7d9e2ea57d
Author | SHA1 | Date |
---|---|---|
|
7d9e2ea57d | |
|
5ef862f5fc | |
|
cab275bc49 |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -81,25 +81,6 @@ export async function getInputs(): Promise<Inputs> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sanitizeInputs(inputs: Inputs) {
|
|
||||||
const res = {};
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
res[key] = value;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
export async function getArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||||
const context = handlebars.compile(inputs.context)({
|
const context = handlebars.compile(inputs.context)({
|
||||||
defaultContext: Context.gitContext()
|
defaultContext: Context.gitContext()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import {Build} from '@docker/actions-toolkit/lib/buildx/build';
|
||||||
|
|
||||||
import {Inputs, sanitizeInputs} from './context';
|
import {Inputs} from './context';
|
||||||
|
|
||||||
export const tmpDir = process.env['STATE_tmpDir'] || '';
|
export const tmpDir = process.env['STATE_tmpDir'] || '';
|
||||||
export const inputs = process.env['STATE_inputs'] ? JSON.parse(process.env['STATE_inputs']) : undefined;
|
export const inputs = process.env['STATE_inputs'] ? JSON.parse(process.env['STATE_inputs']) : undefined;
|
||||||
|
@ -22,3 +23,39 @@ export function setBuildRef(buildRef: string) {
|
||||||
export function setSummarySupported() {
|
export function setSummarySupported() {
|
||||||
core.saveState('isSummarySupported', 'true');
|
core.saveState('isSummarySupported', 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sanitizeInputs(inputs: Inputs) {
|
||||||
|
const res = {};
|
||||||
|
for (const key of Object.keys(inputs)) {
|
||||||
|
if (key === 'github-token') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const value: string | string[] | boolean = inputs[key];
|
||||||
|
if (typeof value === 'boolean' && !value) {
|
||||||
|
continue;
|
||||||
|
} else if (Array.isArray(value)) {
|
||||||
|
if (value.length === 0) {
|
||||||
|
continue;
|
||||||
|
} else if (key === 'secrets' && value.length > 0) {
|
||||||
|
const secretKeys: string[] = [];
|
||||||
|
for (const secret of value) {
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
const [skey, _] = Build.parseSecretKvp(secret);
|
||||||
|
secretKeys.push(skey);
|
||||||
|
} catch (err) {
|
||||||
|
// ignore invalid secret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (secretKeys.length > 0) {
|
||||||
|
res[key] = secretKeys;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (!value) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
res[key] = value;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue