Skip to content

Commit a2c3f02

Browse files
Use sudo when creating cache destination.
This allows us to cache dirs at root (e.g. /nix).
1 parent 371e145 commit a2c3f02

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

dist/index/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -27244,8 +27244,10 @@ async function restoreLocalCache(cachePaths) {
2724427244
await io.rmRF(p.pathInCache);
2724527245
}
2724627246
const expandedFilePath = resolveHome(p.mountTarget);
27247-
await io.mkdirP(expandedFilePath);
2724827247
await io.mkdirP(p.pathInCache);
27248+
// Sudo to be able to create dirs in root (e.g. /nix).
27249+
// Use `install` instead of `mkdir -p` to easily set owners.
27250+
await lib_exec.exec(`sudo install -d -o runner -g docker ${expandedFilePath}`);
2724927251
await lib_exec.exec(`sudo mount --bind ${p.pathInCache} ${expandedFilePath}`);
2725027252
}
2725127253
return cacheMisses;

src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ export async function restoreLocalCache(
8686
}
8787

8888
const expandedFilePath = utils.resolveHome(p.mountTarget);
89-
await io.mkdirP(expandedFilePath);
9089
await io.mkdirP(p.pathInCache);
90+
// Sudo to be able to create dirs in root (e.g. /nix).
91+
// Use `install` instead of `mkdir -p` to easily set owners.
92+
await exec.exec(`sudo install -d -o runner -g docker ${expandedFilePath}`);
9193
await exec.exec(`sudo mount --bind ${p.pathInCache} ${expandedFilePath}`);
9294
}
9395

0 commit comments

Comments
 (0)