Merged
Conversation
Add optional `cache` and `cache-dir` inputs to enable Astro build caching, speeding up subsequent builds by caching optimized images and other assets. This reduces build times in CI/CD pipelines.
There was a problem hiding this comment.
Pull request overview
This PR adds automatic caching of Astro's build artifacts to improve build performance across workflow runs. The implementation enables caching by default while maintaining full backward compatibility.
Key Changes:
- Added two new optional inputs:
cache(enable/disable caching, defaults to"true") andcache-dir(custom cache directory path, defaults to"node_modules/.astro") - Integrated
actions/cache/restoreandactions/cache/savesteps into the build workflow - Updated documentation to describe the new caching inputs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| action.yml | Added cache input definitions and implemented cache restore/save steps around the build process |
| README.md | Added documentation for the new cache and cache-dir input parameters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #89
Overview
This PR adds support for caching Astro's build artifacts (optimized images and other assets) between workflow runs, significantly improving build performance for subsequent runs.
Problem
As discussed in #89, Astro maintains its own cache directory (default:
node_modules/.astro) that stores optimized images and other build artifacts. Without caching this directory, every workflow run needs to re-optimize the same images, which can add significant time to builds - especially for sites with many images.While
actions/setup-nodecaches the npm package store, it does not cache Astro's build artifacts, which live innode_modules/.astro.Solution
This PR implements automatic caching of Astro's build directory using
actions/cache:astro-cache-${runner.os}-${github.sha}with fallback toastro-cache-${runner.os}-to allow reusing caches across commits while maintaining OS-specific cachesChanges
New Inputs
cache(optional, default:"true")"false"to disable caching (useful for debugging)cache-dir(optional, default:"node_modules/.astro")pathinput)cacheDirin their Astro configImplementation Details
actions/cache/[email protected]to restore cache before buildactions/cache/[email protected]to save cache after build (only if cache wasn't hit)Testing
Test Methodology
cache: "true"Test Results
Evidence of caching working: Workflow Run #58564230627
Key log lines showing cache reuse:
Cache Behavior Verified
Backwards Compatibility
This change is fully backwards compatible:
cache: "false"Usage Examples
Default (caching enabled)
Explicitly enable caching
Disable caching (for debugging)
Custom cache directory