Save only when new images were created #82
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As described in #81, this action often saves a new cache even though no new images were created. This happens when there were images preloaded and then the action restored a cache successfully.
In that case, checkIfImageHasAdded returns true because existingImages includes the preloaded images as well as the restored ones. That bypasses this check:
action-docker-layer-caching/post.ts
Line 24 in b01c39f
Then getImagesShouldSave returns the list of restored images, so the next check passes because imagesToSave isn't empty.
action-docker-layer-caching/post.ts
Line 30 in b01c39f
This change ignores restored images when checking if new images were created. When new image(s) are detected they're saved with the restored images in the new cache. This is so that unchanged images aren't lost when other images are rebuilt.
Fixes #81