@@ -27,17 +27,20 @@ export interface CacheOpts {
2727 htcVersion : string ;
2828 baseCacheDir : string ;
2929 cacheFile : string ;
30+ ghaNoCache ?: boolean ;
3031}
3132
3233export class Cache {
3334 private readonly opts : CacheOpts ;
3435 private readonly ghaCacheKey : string ;
36+ private readonly ghaNoCache ?: boolean ;
3537 private readonly cacheDir : string ;
3638 private readonly cachePath : string ;
3739
3840 constructor ( opts : CacheOpts ) {
3941 this . opts = opts ;
4042 this . ghaCacheKey = util . format ( '%s-%s-%s' , this . opts . htcName , this . opts . htcVersion , this . platform ( ) ) ;
43+ this . ghaNoCache = this . opts . ghaNoCache ;
4144 this . cacheDir = path . join ( this . opts . baseCacheDir , this . opts . htcVersion , this . platform ( ) ) ;
4245 this . cachePath = path . join ( this . cacheDir , this . opts . cacheFile ) ;
4346 if ( ! fs . existsSync ( this . cacheDir ) ) {
@@ -52,7 +55,7 @@ export class Cache {
5255 const htcPath = await tc . cacheDir ( this . cacheDir , this . opts . htcName , this . opts . htcVersion , this . platform ( ) ) ;
5356 core . debug ( `Cache.save cached to hosted tool cache ${ htcPath } ` ) ;
5457
55- if ( cache . isFeatureAvailable ( ) ) {
58+ if ( ! this . ghaNoCache && cache . isFeatureAvailable ( ) ) {
5659 core . debug ( `Cache.save caching ${ this . ghaCacheKey } to GitHub Actions cache` ) ;
5760 await cache . saveCache ( [ this . cacheDir ] , this . ghaCacheKey ) ;
5861 }
@@ -67,14 +70,16 @@ export class Cache {
6770 return this . copyToCache ( `${ htcPath } /${ this . opts . cacheFile } ` ) ;
6871 }
6972
70- if ( cache . isFeatureAvailable ( ) ) {
73+ if ( ! this . ghaNoCache && cache . isFeatureAvailable ( ) ) {
7174 core . debug ( `GitHub Actions cache feature available` ) ;
7275 if ( await cache . restoreCache ( [ this . cacheDir ] , this . ghaCacheKey ) ) {
7376 core . info ( `Restored ${ this . ghaCacheKey } from GitHub Actions cache` ) ;
7477 htcPath = await tc . cacheDir ( this . cacheDir , this . opts . htcName , this . opts . htcVersion , this . platform ( ) ) ;
7578 core . info ( `Restored to hosted tool cache ${ htcPath } ` ) ;
7679 return this . copyToCache ( `${ htcPath } /${ this . opts . cacheFile } ` ) ;
7780 }
81+ } else if ( this . ghaNoCache ) {
82+ core . info ( `GitHub Actions cache disabled` ) ;
7883 } else {
7984 core . info ( `GitHub Actions cache feature not available` ) ;
8085 }
0 commit comments