forked from OpenUpSA/opengazettes
-
Notifications
You must be signed in to change notification settings - Fork 3
/
deploy.sh
executable file
·42 lines (34 loc) · 1.02 KB
/
deploy.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#
# Cleans and deploys the project to S3.
#
# Usage:
# ./deploy.sh
#
# This script gets the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from your .env file
# It will fail if those are not present
# Initialize some vars
. .env
export DEPLOY_DIR=".deploy"
bundle exec jekyll build
# Copy the site directory to a temporary location so that modifications we make
# don't get overwritten by the Jekyll server that is potentially running
mkdir -p $DEPLOY_DIR
cp -a _site/. $DEPLOY_DIR
for file in $DEPLOY_DIR/gazettes/KE/*.html; do
if [ $file != "$DEPLOY_DIR/gazettes/KE/index.html" ];
then
mv "$file" "$DEPLOY_DIR/gazettes/KE/`basename "$file" .html`"
fi
done
for file in $DEPLOY_DIR/*.html; do
if [ $file != "$DEPLOY_DIR/index.html" ];
then
mv "$file" "$DEPLOY_DIR/`basename "$file" .html`"
fi
done
# Go through sitemap.xml and remove occurences of `.html`
sed -e 's/.html//g' _site/sitemap.xml > $DEPLOY_DIR/sitemap.xml
s3_website push --site=$DEPLOY_DIR
# Cleanup
rm -r $DEPLOY_DIR