Browse Source

Added variables to deploy script

master
Kim Grytøyr 3 years ago
parent
commit
c150118392
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      deploy.sh

+ 6
- 4
deploy.sh View File

@@ -1,4 +1,6 @@
#!/bin/bash
distribution_id="E1B9KWNF6O30FL" # Cloudfront distribution ID
bucket_name="kim-grytoyr-io" # S3 bucket name

# Clean the public folder, Hugo doesn't do this for you
echo "Cleaning public folder.."
@@ -9,8 +11,8 @@ 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
echo "Deploying to S3 bucket $bucket_name.."
aws s3 sync ./public s3://$bucket_name --delete --size-only > .sync.log

# Truncate temporary files
echo "Creating list of changed files.."
@@ -20,7 +22,7 @@ echo "Creating list of changed files.."
# 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
sed "s/^.*$bucket_name//" | tr -d '[:blank:]' > .changed-files
done < .sync.log

# Replace the newlines with spaces for --path flag
@@ -34,7 +36,7 @@ then
else
# Changes made. Invalidate changed paths in Cloudfront
echo "Invalidating cache.."
aws cloudfront create-invalidation --distribution-id E1B9KWNF6O30FL --paths $(cat .paths) >/dev/null
aws cloudfront create-invalidation --distribution-id $distribution_id --paths $(cat .paths) >/dev/null
fi

echo "Deployed!"

Loading…
Cancel
Save