Browse Source

Added comments to deploy script

master
Kim Grytøyr 3 years ago
parent
commit
ac6278632b
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      deploy.sh

+ 9
- 2
deploy.sh View File

@@ -1,33 +1,40 @@
#!/bin/bash

# Clean the public folder, Hugo doesn't do this for you
echo "Cleaning public folder.."
rm -rf ./public

# Build the website
echo "Building website.."
hugo >/dev/null

# Sync with S3 bucket. Delete from S3 if necessary, and only use file size for matching files
echo "Deploying.."
aws s3 sync ./public s3://kim-grytoyr-io --delete --size-only > .sync.log

# Truncate temporary files
echo "Creating list of changed files.."
> .changed-files
> .paths

# Parse the log from S3 sync and remove everything but paths
while read -r line
do
sed 's/^.*kim-grytoyr-io//' | tr -d '[:blank:]' > .changed-files
done < .sync.log

# Replace the newlines with spaces for --path flag
tr '\r\n' ' ' < .changed-files > .paths

# Check if .paths is empty
if [ ! -s .paths ]
then
# No changes made
echo "No changes, nothing to invalidate.."
else
# Changes made. Invalidate changed paths in Cloudfront
echo "Invalidating cache.."
aws cloudfront create-invalidation --distribution-id E1B9KWNF6O30FL --paths $(cat .paths) >/dev/null
fi

echo "Deployed!"



Loading…
Cancel
Save