-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add some logging to validate behavior * More logging * Additional logging * Fix logging * Fix flag name * More logging * Fix broken logging * discard all regular cache layers * Stop tar complaining about absolute paths * More logging, more pruning * Fix incorrect variable name * Remember to start the buildx builder again * Clean things up a bit * Fix flag * start docker buildx back up so that we can log the cache state * start docker buildx back up so that we can log the cache state
- Loading branch information
Showing
2 changed files
with
53 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,61 @@ | ||
const core = require('@actions/core'); | ||
const core = require("@actions/core"); | ||
|
||
const { exec } = require('child_process'); | ||
const { promisify } = require('util'); | ||
const { exec } = require("child_process"); | ||
const { promisify } = require("util"); | ||
|
||
const execAsync = promisify(exec); | ||
|
||
const builder = core.getInput('builder'); | ||
const path = core.getInput('cache-path'); | ||
const builder = core.getInput("builder"); | ||
const path = core.getInput("cache-path"); | ||
|
||
async function post() { | ||
try { | ||
await execAsync(`docker buildx prune --force --keep-storage ${ core.getInput('cache-max-size')}`) | ||
core.info("Before pruning:"); | ||
var {stdout, stderr} = await execAsync(`docker buildx du`); | ||
core.info(`stdout:\n${stdout}\n`); | ||
if (stderr) { core.error(`stderr:\n${stderr}\n`); } | ||
|
||
await execAsync(`docker run --rm \ | ||
--volumes-from ${ builder } \ | ||
-v ${ path }:/cache \ | ||
alpine /bin/sh -c "cd / && tar cf /cache/buildkit-state.tar /var/lib/buildkit"`); | ||
var {stdout, stderr} = await execAsync(`docker buildx prune --force --filter type=regular`); | ||
core.info(`stdout:\n${stdout}\n`); | ||
if (stderr) { core.error(`stderr:\n${stderr}\n`); } | ||
|
||
core.info('Cache archived successfully'); | ||
var {stdout, stderr} = await execAsync(`docker buildx prune --force --filter type=source.local`); | ||
core.info(`stdout:\n${stdout}\n`); | ||
if (stderr) { core.error(`stderr:\n${stderr}\n`); } | ||
|
||
var {stdout, stderr} = await execAsync(`docker buildx prune --force --filter type=frontend`); | ||
core.info(`stdout:\n${stdout}\n`); | ||
if (stderr) { core.error(`stderr:\n${stderr}\n`); } | ||
|
||
var {stdout, stderr} = await execAsync(`docker buildx prune --force --filter type=internal`); | ||
core.info(`stdout:\n${stdout}\n`); | ||
if (stderr) { core.error(`stderr:\n${stderr}\n`); } | ||
|
||
var {stdout, stderr} = await execAsync(`docker buildx prune --force --filter type=exec.cachemount --keep-storage ${core.getInput('cache-max-size')}`); | ||
core.info(`stdout:\n${stdout}\n`); | ||
if (stderr) { core.error(`stderr:\n${stderr}\n`); } | ||
|
||
core.info("After pruning:"); | ||
|
||
var {stdout, stderr} = await execAsync(`docker buildx du`); | ||
core.info(`stdout:\n${stdout}\n`); | ||
if (stderr) { core.error(`stderr:\n${stderr}\n`); } | ||
|
||
var {stdout, stderr} = await execAsync(`docker buildx du --verbose`); | ||
core.info(`stdout:\n${stdout}\n`); | ||
if (stderr) { core.error(`stderr:\n${stderr}\n`); } | ||
|
||
var {stdout, stderr} = await execAsync(`docker run --rm \ | ||
--volumes-from ${builder} \ | ||
-v ${path}:/cache \ | ||
alpine /bin/sh -c "cd / && tar cf /cache/buildkit-state.tar var/lib/buildkit"`); | ||
core.info(`stdout:\n${stdout}\n`); | ||
if (stderr) { core.error(`stderr:\n${stderr}\n`); } | ||
|
||
core.info("Cache archived successfully"); | ||
} catch (error) { | ||
core.error(`Cache archive failed: ${ error }`); | ||
core.error(`Cache archive failed: ${error}`); | ||
} | ||
} | ||
|
||
post() | ||
post(); |