Skip to content

Use cache@v2, sync static resources on deploy #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/deploy-prd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
cache-dependency-path: "**/package-lock.json"

- name: Gatsby main cache
uses: actions/cache@v1
uses: actions/cache@v2
id: gatsby-cache-folder
with:
path: .cache
Expand All @@ -29,7 +29,7 @@ jobs:
${{ runner.os }}-cache-gatsby-

- name: Gatsby Public Folder
uses: actions/cache@v1
uses: actions/cache@v2
id: gatsby-public-folder
with:
path: public/
Expand All @@ -49,8 +49,12 @@ jobs:
aws-region: us-west-1

- name: Sync all cacheable assets
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 }}/
# Don't cache any HTML or JSON file: they should always be up-to-date
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 }}/

- name: Sync all non-cacheable assets
# Don't cache any HTML or JSON file: they should always be up-to-dates
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 }}/

# - name: Sync static resources
# # Sync the static resources in a separate pass: their URL is static but we might update the contents once in a while
# run: aws s3 sync --cache-control "public, max-age=14400" --delete public/resources/ s3://${{ secrets.PROD_AWS_S3_BUCKET_NAME }}/resources/
14 changes: 9 additions & 5 deletions .github/workflows/deploy-stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
cache-dependency-path: "**/package-lock.json"

- name: Gatsby main cache
uses: actions/cache@v1
uses: actions/cache@v2
id: gatsby-cache-folder
with:
path: .cache
Expand All @@ -33,7 +33,7 @@ jobs:
${{ runner.os }}-cache-gatsby-

- name: Gatsby Public Folder
uses: actions/cache@v1
uses: actions/cache@v2
id: gatsby-public-folder
with:
path: public/
Expand All @@ -53,8 +53,12 @@ jobs:
aws-region: us-west-1

- name: Sync all cacheable assets
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 }}/
# Don't cache any HTML or JSON file: they should always be up-to-date
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 }}/

- name: Sync all non-cacheable assets
# Don't cache any HTML or JSON file: they should always be up-to-dates
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 }}/

- name: Sync static resources
# Sync the static resources in a separate pass: their URL is static but we might update them once in a while
run: aws s3 sync --cache-control "public, max-age=14400" --delete public/resources/ s3://${{ secrets.STAG_AWS_S3_BUCKET_NAME }}/resources/