diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2018-03-10 20:56:37 -0500 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2018-03-10 20:56:37 -0500 |
| commit | d3a7300dc8342111a1ba30d6e2ad95e608a7363b (patch) | |
| tree | 2cad6671e3d61b9638cddb9d54969812a35c08f1 /bin | |
| parent | 57a0b91171ff5e93f13c2ba4bad485641b65ec3b (diff) | |
Infrastructure for publishing the site to S3/CloudFormation.
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/publish-s3 | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/publish-s3 b/bin/publish-s3 new file mode 100755 index 0000000..caefd67 --- /dev/null +++ b/bin/publish-s3 @@ -0,0 +1,34 @@ +#!/bin/bash -e + +BLIKI_BASE="$(dirname "$(dirname "$0")")" +HTML="$BLIKI_BASE/.html" + +BUCKET="$1" + +find "$HTML" -type f | while read SOURCE; do + HTML_PATH="${SOURCE#$HTML/}" + case "$HTML_PATH" in + index.html) + KEY="$HTML_PATH" + CONTENT_TYPE="text/html; charset=UTF-8" + ;; + */index.html) + KEY="$HTML_PATH" + CONTENT_TYPE="text/html; charset=UTF-8" + ;; + *.html) + KEY="${HTML_PATH%.html}" + CONTENT_TYPE="text/html; charset=UTF-8" + ;; + *.css) + KEY="${HTML_PATH}" + CONTENT_TYPE="text/css" + ;; + *) + KEY="$HTML_PATH" + CONTENT_TYPE="$(file --mime-type -b "${SOURCE}")" + ;; + esac + + aws s3 cp --content-type "$CONTENT_TYPE" "$SOURCE" "s3://$BUCKET/$KEY" +done |
