Skip to content

Commit 5bc509d

Browse files
nadiamoeRoberto Santalla
authored andcommitted
ci/pr-deploy: use git ref in cache key, but restore optimistically
This will create different caches for each PR, and restore the most recent cache (that still matches gatsby config files) if there is not a cache entry for a particular PR. This allows to keep the cache fresh, as the cache is not re-uploaded if `key` hits, but _is_ reuploaded if restore-keys. As the most recent key is fetched from `restore-keys`, this ensures we keep refreshing the cache instead of using always the same one that could have been generated a long time ago.
1 parent 6b363f3 commit 5bc509d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

.github/workflows/pr-deploy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ jobs:
110110
public
111111
# Cache will not be used by Gatsby if the following files change:
112112
# https://www.gatsbyjs.com/docs/build-caching/
113-
key: pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}
113+
key: pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ github.ref }}
114+
restore-keys: |
115+
pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-
114116
115117
- name: Build
116118
run: npm run build

0 commit comments

Comments
 (0)