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