11#! /bin/bash
22set -xe
33
4- s3Key=$1
5- s3Secret=$2
6- tag=$3
4+ tag=$1
75folder=" noVNC"
86cdn=" \/\/static-assets.codio.com\/${folder} \/${tag} "
97
@@ -17,16 +15,20 @@ replaceTagVersion () {
1715
1816replaceJsUrls () {
1917 sed -i " s/\.\/package\.json/${cdn} \/package\.json/" " ./app/ui.js"
18+ sed -i " s/\" app\//\" ${cdn} \/app\//" " ./app/ui.js"
2019}
2120
2221prepareSources () {
2322 replaceHtmlUrls " href=\" app\/" " href=\" ${cdn} \/app\/"
2423 replaceHtmlUrls " src=\" app\/" " src=\" ${cdn} \/app\/"
24+ replaceHtmlUrls " from \" .\/" " from \" ${cdn} \/"
25+ replaceHtmlUrls " from '.\/" " from '${cdn} \/"
26+ replaceHtmlUrls " fetch('.\/" " fetch('${cdn} \/"
2527 replaceTagVersion
2628 replaceJsUrls
2729}
2830
29- readarray -d ' ' files < <( find ./ -type f -print0)
31+ readarray -d ' ' files < <( find ./ -type f -not -path " */.git/* " -not -path " */.github/* " - print0)
3032
3133getContentType () {
3234 filename=$1
@@ -58,16 +60,9 @@ uploadFile () {
5860 fName=" ${file# ./ } "
5961 contentType=$2
6062 bucket=" codio-assets"
61- resource=" /${bucket} /${folder} /${tag} /${fName} "
62- dateValue=$( date -R)
63- stringToSign=" PUT\n\n${contentType} \n${dateValue} \n${resource} "
64- signature=$( echo -en " ${stringToSign} " | openssl sha1 -hmac " ${s3Secret} " -binary | base64)
65- curl -X PUT -T " ${file} " \
66- -H " Host: ${bucket} .s3.amazonaws.com" \
67- -H " Date: ${dateValue} " \
68- -H " Content-Type: ${contentType} " \
69- -H " Authorization: AWS ${s3Key} :${signature} " \
70- https://${bucket} .s3.amazonaws.com/" ${folder} " /" ${tag} " /" ${fName} " || exit 1
63+ resource=" s3://${bucket} /${folder} /${tag} /${fName} "
64+
65+ aws s3 cp " ${file} " " ${resource} " --cache-control no-cache --content-type " ${contentType} "
7166}
7267
7368prepareSources
0 commit comments