forked from abinmn/gcp-storage-bucket-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
26 lines (23 loc) · 1.71 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
#Decode Base64-key to json file
echo "$INPUT_SERVICE_KEY" | base64 --decode > "$HOME"/service_key.json
gcloud auth activate-service-account --key-file="$HOME"/service_key.json --project "$INPUT_PROJECT"
cd "$INPUT_BUILD_FOLDER"
gsutil -h "Cache-Control:no-cache,no-store,must-revalidate" -m cp -z "css,js,html,svg,json" -r . gs://"$INPUT_BUCKET_NAME"
gsutil web set -m "$INPUT_HOME_PAGE_PATH" -e "$INPUT_ERROR_PAGE_PATH" gs://"$INPUT_BUCKET_NAME"
gsutil -m setmeta -h "Cache-Control:public, max-age=31536000" gs://"$INPUT_BUCKET_NAME"/**/*.js
gsutil -m setmeta -h "Cache-Control:public, max-age=31536000" gs://"$INPUT_BUCKET_NAME"/**/*.css
gsutil -m setmeta -h "Cache-Control:public, max-age=31536000" gs://"$INPUT_BUCKET_NAME"/**/*.svg
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/**/*
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
gsutil -m setmeta -h "Cache-Control:no-cache,no-store,must-revalidate" gs://"$INPUT_BUCKET_NAME"/**/page-data.*.json
gsutil -m setmeta -h "Cache-Control:no-cache,no-store,must-revalidate" gs://"$INPUT_BUCKET_NAME"/**/app-data.json