mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-23 01:03:57 +08:00
save
This commit is contained in:
parent
2377d067bc
commit
a51ff9983a
2 changed files with 11 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cache",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"private": true,
|
||||
"description": "Cache dependencies and build outputs",
|
||||
"main": "dist/restore/index.js",
|
||||
|
|
|
@ -36,6 +36,8 @@ export class CacheService {
|
|||
}
|
||||
|
||||
async saveCache(paths: string[], key: string): Promise<string> {
|
||||
const cacheId: string = this.getCacheId(key);
|
||||
|
||||
const compressionMethod = await utils.getCompressionMethod();
|
||||
|
||||
const cachePaths = await utils.resolvePaths(paths);
|
||||
|
@ -60,8 +62,8 @@ export class CacheService {
|
|||
`Archive Size: ${filesize(fs.statSync(archivePath).size)}`
|
||||
);
|
||||
|
||||
core.debug(`Saving Cache (ID: ${key})`);
|
||||
await this.uploadToS3(key, archivePath);
|
||||
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||||
await this.uploadToS3(cacheId, archivePath);
|
||||
} finally {
|
||||
// Try to delete the archive to save space
|
||||
try {
|
||||
|
@ -89,4 +91,10 @@ export class CacheService {
|
|||
})
|
||||
.promise();
|
||||
}
|
||||
|
||||
private getCacheId(primaryKey: string): string {
|
||||
return `${process.env["GITHUB_REPOSITORY"]
|
||||
?.replace("/", "-")
|
||||
.toLowerCase()}-${primaryKey}`;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue