mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
Merge pull request #416 from crazy-max/docker-daemon-up
buildx(history): check docker daemon is running before exporting
This commit is contained in:
commit
f7a8b21610
@ -20,6 +20,12 @@ import {Docker} from '../../src/docker/docker';
|
||||
|
||||
const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip;
|
||||
|
||||
maybe('isDaemonRunning', () => {
|
||||
it('checks if daemon is running', async () => {
|
||||
expect(await Docker.isDaemonRunning()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
maybe('pull', () => {
|
||||
// prettier-ignore
|
||||
test.each([
|
||||
|
@ -50,6 +50,9 @@ export class History {
|
||||
if (!(await Docker.isAvailable())) {
|
||||
throw new Error('Docker is required to export a build record');
|
||||
}
|
||||
if (!(await Docker.isDaemonRunning())) {
|
||||
throw new Error('Docker daemon is not running, skipping build record export');
|
||||
}
|
||||
if (!(await this.buildx.versionSatisfies('>=0.13.0'))) {
|
||||
throw new Error('Buildx >= 0.13.0 is required to export a build record');
|
||||
}
|
||||
|
@ -54,6 +54,17 @@ export class Docker {
|
||||
});
|
||||
}
|
||||
|
||||
public static async isDaemonRunning(): Promise<boolean> {
|
||||
try {
|
||||
await Docker.getExecOutput([`version`], {
|
||||
silent: true
|
||||
});
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static async exec(args?: string[], options?: ExecOptions): Promise<number> {
|
||||
return Exec.exec('docker', args, Docker.execOptions(options));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user