-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add no-cache to service worker and manifest (#291)
- Loading branch information
1 parent
f8f1f75
commit 7375231
Showing
5 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
# This workflow is used to set the cache-control header of the app's index.html file | ||
# This workflow is used to set the cache-control header of sensitive files, namely | ||
# - index.html | ||
# - sw.js | ||
# - manifest.webmanifest | ||
# (which should in general be set to `no-cache`). | ||
|
||
name: Set Index Cache Control | ||
name: Set Cache Control | ||
|
||
on: | ||
workflow_dispatch: | ||
|
@@ -11,11 +14,12 @@ on: | |
# eg. "max-age=86400" or "no-cache" | ||
type: string | ||
ENVIRONMENT: | ||
description: "Environment to set the cache control header of index.html" | ||
description: "Environment to set the cache control header for sensitive files" | ||
required: true | ||
default: "zetta" | ||
type: choice | ||
options: | ||
- "epsilon" | ||
- "zetta" | ||
- "gamma" | ||
- "alpha" | ||
|
@@ -31,7 +35,7 @@ on: | |
type: string | ||
|
||
jobs: | ||
set-index-cache-control: | ||
set-cache-control: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Sets env vars for production | ||
|
@@ -44,11 +48,17 @@ jobs: | |
echo "BUCKET=${{ secrets.STAGING__FRONTEND__S3_BUCKET }}" >> $GITHUB_ENV | ||
if: contains(inputs.ENVIRONMENT, 'gamma') | ||
|
||
- name: Sets env vars for development | ||
- name: Sets env vars for development (zetta) | ||
run: | | ||
echo "BUCKET=${{ secrets.DEV__FRONTEND__S3_BUCKET }}" >> $GITHUB_ENV | ||
if: contains(inputs.ENVIRONMENT, 'zetta') | ||
|
||
- name: Sets env vars for development (epsilon) | ||
run: | | ||
echo "BUCKET=${{ secrets.DEV__FRONTENDV2__S3_BUCKET }}" >> $GITHUB_ENV | ||
if: contains(inputs.ENVIRONMENT, 'epsilon') | ||
|
||
# Set cache for index.html | ||
- uses: keithweaver/[email protected] | ||
with: | ||
command: cp | ||
|
@@ -62,3 +72,33 @@ jobs: | |
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOYER__AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOYER__SECRET_ACCESS_KEY }} | ||
AWS_S3_PATH: s3://${{ env.BUCKET }}/index.html | ||
|
||
# Set cache for sw.js | ||
- uses: keithweaver/[email protected] | ||
with: | ||
command: cp | ||
source: ${{ env.AWS_S3_PATH }} | ||
destination: ${{ env.AWS_S3_PATH }} | ||
flags: "--cache-control ${{ inputs.VALUE }}" | ||
aws_access_key_id: ${{ env.AWS_ACCESS_KEY_ID }} | ||
aws_secret_access_key: ${{ env.AWS_SECRET_ACCESS_KEY }} | ||
aws_region: us-west-1 | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOYER__AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOYER__SECRET_ACCESS_KEY }} | ||
AWS_S3_PATH: s3://${{ env.BUCKET }}/sw.js | ||
|
||
# Set cache for manifest.webmanifest | ||
- uses: keithweaver/[email protected] | ||
with: | ||
command: cp | ||
source: ${{ env.AWS_S3_PATH }} | ||
destination: ${{ env.AWS_S3_PATH }} | ||
flags: "--cache-control ${{ inputs.VALUE }}" | ||
aws_access_key_id: ${{ env.AWS_ACCESS_KEY_ID }} | ||
aws_secret_access_key: ${{ env.AWS_SECRET_ACCESS_KEY }} | ||
aws_region: us-west-1 | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOYER__AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOYER__SECRET_ACCESS_KEY }} | ||
AWS_S3_PATH: s3://${{ env.BUCKET }}/manifest.webmanifest |