mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 15:48:39 +08:00 
			
		
		
		
	resave primary key to state if reeval is true & get state afterward
This commit is contained in:
		
							parent
							
								
									9840f83c99
								
							
						
					
					
						commit
						3d5818e554
					
				
							
								
								
									
										5
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -46782,7 +46782,6 @@ function run() {
 | 
				
			||||||
                    utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
 | 
					                    utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                const state = utils.getCacheState();
 | 
					 | 
				
			||||||
                let primaryKey = "";
 | 
					                let primaryKey = "";
 | 
				
			||||||
                const reeval = core.getBooleanInput(constants_1.Inputs.Reeval);
 | 
					                const reeval = core.getBooleanInput(constants_1.Inputs.Reeval);
 | 
				
			||||||
                if (!reeval) {
 | 
					                if (!reeval) {
 | 
				
			||||||
| 
						 | 
					@ -46790,13 +46789,15 @@ function run() {
 | 
				
			||||||
                    primaryKey = core.getState(constants_1.State.CachePrimaryKey);
 | 
					                    primaryKey = core.getState(constants_1.State.CachePrimaryKey);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else {
 | 
					                else {
 | 
				
			||||||
                    // choose to reevaluate primary key
 | 
					                    // choose to reevaluate primary key - resave state to correctly test cache hit
 | 
				
			||||||
                    primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
 | 
					                    primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
 | 
				
			||||||
 | 
					                    core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (!primaryKey) {
 | 
					                if (!primaryKey) {
 | 
				
			||||||
                    utils.logWarning(`Error retrieving key from state.`);
 | 
					                    utils.logWarning(`Error retrieving key from state.`);
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                const state = utils.getCacheState();
 | 
				
			||||||
                if (utils.isExactKeyMatch(primaryKey, state)) {
 | 
					                if (utils.isExactKeyMatch(primaryKey, state)) {
 | 
				
			||||||
                    core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
 | 
					                    core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,22 +26,23 @@ async function run(): Promise<void> {
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const state = utils.getCacheState();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            let primaryKey = "";
 | 
					            let primaryKey = "";
 | 
				
			||||||
            const reeval = core.getBooleanInput(Inputs.Reeval);
 | 
					            const reeval = core.getBooleanInput(Inputs.Reeval);
 | 
				
			||||||
            if (!reeval) {
 | 
					            if (!reeval) {
 | 
				
			||||||
                // Inputs are reevaluted before the post action, so we want the original key used for restore
 | 
					                // Inputs are reevaluted before the post action, so we want the original key used for restore
 | 
				
			||||||
                primaryKey = core.getState(State.CachePrimaryKey);
 | 
					                primaryKey = core.getState(State.CachePrimaryKey);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                // choose to reevaluate primary key
 | 
					                // choose to reevaluate primary key - resave state to correctly test cache hit
 | 
				
			||||||
                primaryKey = core.getInput(Inputs.Key, { required: true });
 | 
					                primaryKey = core.getInput(Inputs.Key, { required: true });
 | 
				
			||||||
 | 
					                core.saveState(State.CachePrimaryKey, primaryKey);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (!primaryKey) {
 | 
					            if (!primaryKey) {
 | 
				
			||||||
                utils.logWarning(`Error retrieving key from state.`);
 | 
					                utils.logWarning(`Error retrieving key from state.`);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            const state = utils.getCacheState();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (utils.isExactKeyMatch(primaryKey, state)) {
 | 
					            if (utils.isExactKeyMatch(primaryKey, state)) {
 | 
				
			||||||
                core.info(
 | 
					                core.info(
 | 
				
			||||||
                    `Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
 | 
					                    `Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user