Skip to content

Commit 05a25a1

Browse files
authored
Use cache@v2, sync static resources on deploy (#20)
* Use cache@v2 * Sync resources with a separate pass * Disable sync on production, for now
1 parent e9aa6e0 commit 05a25a1

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

.github/workflows/deploy-prd.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
cache-dependency-path: "**/package-lock.json"
2121

2222
- name: Gatsby main cache
23-
uses: actions/cache@v1
23+
uses: actions/cache@v2
2424
id: gatsby-cache-folder
2525
with:
2626
path: .cache
@@ -29,7 +29,7 @@ jobs:
2929
${{ runner.os }}-cache-gatsby-
3030
3131
- name: Gatsby Public Folder
32-
uses: actions/cache@v1
32+
uses: actions/cache@v2
3333
id: gatsby-public-folder
3434
with:
3535
path: public/
@@ -49,8 +49,12 @@ jobs:
4949
aws-region: us-west-1
5050

5151
- name: Sync all cacheable assets
52-
run:
53-
aws s3 sync --cache-control "public, max-age=31536000, immutable" --include "*.css" --include="*.js" --include="*.gif" --include="*.png" --include="*.svg" --exclude "*.html" --exclude="sw.js" --exclude="*.json" --delete public/ s3://${{ secrets.PROD_AWS_S3_BUCKET_NAME }}/
54-
# Don't cache any HTML or JSON file: they should always be up-to-date
52+
run: aws s3 sync --cache-control "public, max-age=31536000, immutable" --include "*.css" --include="*.js" --include="*.gif" --include="*.png" --include="*.svg" --exclude "*.html" --exclude="sw.js" --exclude="*.json" --delete public/ s3://${{ secrets.PROD_AWS_S3_BUCKET_NAME }}/
53+
5554
- name: Sync all non-cacheable assets
55+
# Don't cache any HTML or JSON file: they should always be up-to-dates
5656
run: aws s3 sync --cache-control "public, max-age=0, must-revalidate" --include "*.html" --include="sw.js" --include="*.json" --include "*.css" --exclude="*.js" --exclude="*.gif" --exclude="*.png" --exclude="*.svg" --delete public/ s3://${{ secrets.PROD_AWS_S3_BUCKET_NAME }}/
57+
58+
# - name: Sync static resources
59+
# # Sync the static resources in a separate pass: their URL is static but we might update the contents once in a while
60+
# run: aws s3 sync --cache-control "public, max-age=14400" --delete public/resources/ s3://${{ secrets.PROD_AWS_S3_BUCKET_NAME }}/resources/

.github/workflows/deploy-stg.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
cache-dependency-path: "**/package-lock.json"
2525

2626
- name: Gatsby main cache
27-
uses: actions/cache@v1
27+
uses: actions/cache@v2
2828
id: gatsby-cache-folder
2929
with:
3030
path: .cache
@@ -33,7 +33,7 @@ jobs:
3333
${{ runner.os }}-cache-gatsby-
3434
3535
- name: Gatsby Public Folder
36-
uses: actions/cache@v1
36+
uses: actions/cache@v2
3737
id: gatsby-public-folder
3838
with:
3939
path: public/
@@ -53,8 +53,12 @@ jobs:
5353
aws-region: us-west-1
5454

5555
- name: Sync all cacheable assets
56-
run:
57-
aws s3 sync --cache-control "public, max-age=31536000, immutable" --include "*.css" --include="*.js" --include="*.gif" --include="*.png" --include="*.svg" --exclude "*.html" --exclude="sw.js" --exclude="*.json" --delete public/ s3://${{ secrets.STAG_AWS_S3_BUCKET_NAME }}/
58-
# Don't cache any HTML or JSON file: they should always be up-to-date
56+
run: aws s3 sync --cache-control "public, max-age=31536000, immutable" --include "*.css" --include="*.js" --include="*.gif" --include="*.png" --include="*.svg" --exclude "*.html" --exclude="sw.js" --exclude="*.json" --delete public/ s3://${{ secrets.STAG_AWS_S3_BUCKET_NAME }}/
57+
5958
- name: Sync all non-cacheable assets
59+
# Don't cache any HTML or JSON file: they should always be up-to-dates
6060
run: aws s3 sync --cache-control "public, max-age=0, must-revalidate" --include "*.html" --include="sw.js" --include="*.json" --include "*.css" --exclude="*.js" --exclude="*.gif" --exclude="*.png" --exclude="*.svg" --delete public/ s3://${{ secrets.STAG_AWS_S3_BUCKET_NAME }}/
61+
62+
- name: Sync static resources
63+
# Sync the static resources in a separate pass: their URL is static but we might update them once in a while
64+
run: aws s3 sync --cache-control "public, max-age=14400" --delete public/resources/ s3://${{ secrets.STAG_AWS_S3_BUCKET_NAME }}/resources/

0 commit comments

Comments
 (0)