forked from dashevo/gh-action-cache-buildkit-state
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
30 lines (22 loc) · 808 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const core = require('@actions/core');
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);
const builder = core.getInput('builder');
const path = core.getInput('cache-path');
async function run() {
try {
await execAsync('docker buildx stop');
await execAsync(`docker run --rm \
--volumes-from ${ builder } \
-v ${ path }:/cache \
alpine /bin/sh -c "cd / && tar xf /cache/buildkit-state.tar"`);
core.info('Cache restored successfully');
await execAsync('docker buildx inspect --bootstrap');
var {stdout, stderr} = await execAsync(`docker buildx du --verbose`);
core.info(`Cache now contains:\n${stdout}\n`);
} catch (error) {
core.error(`Cache restore failed: ${ error }`);
}
}
run()