mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-30 23:39:54 +02:00
Allow for multiple line-delimited paths to cache
This commit is contained in:
parent
826785142a
commit
84cead4a82
8 changed files with 116 additions and 58 deletions
26
src/tar.ts
26
src/tar.ts
|
@ -28,20 +28,30 @@ async function execTar(args: string[]): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
export async function extractTar(
|
||||
archivePath: string,
|
||||
targetDirectory: string
|
||||
): Promise<void> {
|
||||
function getWorkingDirectory(): string {
|
||||
return process.env["GITHUB_WORKSPACE"] ?? process.cwd();
|
||||
}
|
||||
|
||||
export async function extractTar(archivePath: string): Promise<void> {
|
||||
// Create directory to extract tar into
|
||||
await io.mkdirP(targetDirectory);
|
||||
const args = ["-xz", "-f", archivePath, "-C", targetDirectory];
|
||||
const workingDirectory = getWorkingDirectory();
|
||||
await io.mkdirP(workingDirectory);
|
||||
const args = ["-xz", "-f", archivePath, "-P", "-C", workingDirectory];
|
||||
await execTar(args);
|
||||
}
|
||||
|
||||
export async function createTar(
|
||||
archivePath: string,
|
||||
sourceDirectory: string
|
||||
sourceDirectories: string[]
|
||||
): Promise<void> {
|
||||
const args = ["-cz", "-f", archivePath, "-C", sourceDirectory, "."];
|
||||
const workingDirectory = getWorkingDirectory();
|
||||
const args = [
|
||||
"-cz",
|
||||
"-f",
|
||||
archivePath,
|
||||
"-C",
|
||||
workingDirectory,
|
||||
sourceDirectories.join(" ")
|
||||
];
|
||||
await execTar(args);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue