Skip to content

Commit

Permalink
update action to set configurable cache headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott van Looy committed Jun 29, 2021
1 parent ba1022a commit 3073cf7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ inputs:
bucket_name:
description: 'Bucket name'
required: true
html_ttl:
description: "How long will the HTML files be allowed to be cached for?"
required: true
project:
description: 'Name of the project that contains the storage bucket.'
required: true
Expand All @@ -26,5 +29,3 @@ inputs:
runs:
using: 'docker'
image: 'Dockerfile'


10 changes: 8 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@ gsutil -m setmeta -h "Cache-Control:public, max-age=31536000" gs://"$INPUT_BUCKE
gsutil -m setmeta -h "Cache-Control:public, max-age=31536000" gs://"$INPUT_BUCKET_NAME"/**/*.woff
gsutil -m setmeta -h "Cache-Control:public, max-age=31536000" gs://"$INPUT_BUCKET_NAME"/**/*.woff2
gsutil -m setmeta -h "Cache-Control:public, max-age=31536000" gs://"$INPUT_BUCKET_NAME"/static/**/*
gsutil -m setmeta -h "Cache-Control:public, max-age=20" gs://"$INPUT_BUCKET_NAME"/**/*.json
gsutil -m setmeta -h "Cache-Control:public, max-age=20" gs://"$INPUT_BUCKET_NAME"/**/*.html
if [ "$INPUT_HTML_TTL" -eq "0" ]
then
gsutil -m setmeta -h "Cache-Control:no-cache,no-store,must-revalidate" gs://"$INPUT_BUCKET_NAME"/**/*.json
gsutil -m setmeta -h "Cache-Control:no-cache,no-store,must-revalidate" gs://"$INPUT_BUCKET_NAME"/**/*.html
else
gsutil -m setmeta -h "Cache-Control:public, max-age="$INPUT_HTML_TTL gs://"$INPUT_BUCKET_NAME"/**/*.json
gsutil -m setmeta -h "Cache-Control:public, max-age="$INPUT_HTML_TTL gs://"$INPUT_BUCKET_NAME"/**/*.html
fi

0 comments on commit 3073cf7

Please sign in to comment.