As a hip, cutting edge developer, you’re using Hugo to generate your blog or website. Wordpress… pssh, you’re way too cool for that. Being cool has its complications though. How and where should you deploy your Hugo app. Should you push it locally using rsync or some other fancy means? Whatever. This simple post is going to show you how to deploy your Hugo app using Gitlab’s Continous Integration feature.
#!/bin/bash CURR_COMMIT=$(git rev-parse HEAD); CURR_VERSION=$(node -e "console.log(require('./package.json').version);"); VER_HASH=$(git rev-list -n 1 v$CURR_VERSION); # Don't want to redo version bump if [ $CURR_COMMIT == $VER_HASH ] then echo 'Already up to date' exit fi npm version patch; NEW_VERSION=$(node -e "console.log(require('./package.json').version);"); echo $NEW_VERSION; git push origin head; npm run buildprod aws s3 sync ./public s3://www.example.com --size-only --delete; # Invalidate cache aws cloudfront create-invalidation \ --distribution-id YOUR_DISTRIBUTION_ID \ --paths "/*"; What Does It Do?
This is the holy grail, the culmination of knowing there is something out there better, stronger, faster. In this blog post, I’ll outline how to set up Amazon S3, Cloudfront, and Route53 to serve your static React, Angular, or any site over HTTPS. Get ready, it’s about to get real. What am I even talking about? The new en vogue way to build sites is to use React or Angular on the front end.
The Backstory You may find yourself needing to redirect all traffic from your root domain example.com, otherwise known as the apex, to your real hostname www.example.com. Maybe you didn’t know this, but you cannot use a CNAME on your apex domain. This will bite you in the butt when you try to use your root domain example.com with Heroku’s SSL (HTTPS) service. Heroku will give you a hostname and tell you to create a CNAME to that hostname.