mirror of
https://github.com/dagger/dagger-for-github.git
synced 2026-01-03 05:29:52 +11:00
Since we published https://github.com/dagger/dagger/releases/tag/v0.3.6 (Nov. 30, 2022), this action started downloading that version (i.e. `latest`), which resulted in breakage, as described in the issue that this fixes. As soon as all tests pass and this gets the OK + merge, we should: 1. Cut a new release for this action (I am thinking v3.2.0) 2. Update the v3 tag to point to this new version That should fix this for all existing GitHub Actions users without any intervention on their part. Fixes https://github.com/dagger/dagger-for-github/issues/80 Signed-off-by: Gerhard Lazu <gerhard@dagger.io>
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import fs from 'fs';
|
|
import * as os from 'os';
|
|
import path from 'path';
|
|
import * as core from '@actions/core';
|
|
|
|
let _tmpDir: string;
|
|
|
|
export function tmpDir(): string {
|
|
if (!_tmpDir) {
|
|
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'dagger-')).split(path.sep).join(path.posix.sep);
|
|
}
|
|
return _tmpDir;
|
|
}
|
|
|
|
export interface Inputs {
|
|
version: string;
|
|
workdir: string;
|
|
args: string;
|
|
installOnly: boolean;
|
|
cleanup: boolean;
|
|
cmds: string[];
|
|
}
|
|
|
|
export async function getInputs(): Promise<Inputs> {
|
|
return {
|
|
version: core.getInput('version') || '0.2',
|
|
workdir: core.getInput('workdir') || '.',
|
|
args: core.getInput('args'),
|
|
installOnly: core.getBooleanInput('install-only'),
|
|
cleanup: core.getBooleanInput('cleanup'),
|
|
cmds: await getInputList('cmds')
|
|
};
|
|
}
|
|
|
|
export async function getInputList(name: string, ignoreComma?: boolean): Promise<string[]> {
|
|
const items = core.getInput(name);
|
|
if (items == '') {
|
|
return [];
|
|
}
|
|
return items
|
|
.split(/\r?\n/)
|
|
.filter(x => x)
|
|
.reduce<string[]>((acc, line) => acc.concat(!ignoreComma ? line.split(',').filter(x => x) : line).map(pat => pat.trim()), []);
|
|
}
|
|
|
|
export const asyncForEach = async (array, callback) => {
|
|
for (const index in array) {
|
|
await callback(array[index], index, array);
|
|
}
|
|
};
|