What is this about?
So I decided to go with Hugo, as everyone seems to do.
I know, everyone is still using Wordpress and they are right.
It is much easier to use and for a normal person, a simple wordpress setup is something you could manage in less than a weekend.
And by normal person I mean someone that has never seen a php hosting and a mysql database.
My latest wordpress installation took 20 minutes, including the 19 minutes of uploading files to the host (yep, a cheap one for a good - but non-paying - friend).
Why Hugo?
As I stated in my previous post, I wanted to write a small and easy blog to keep track of all my thoughts, about work, life and stuff.
Even if I don’t know if I’m going to achieve that target, I want to try at least.
I chose Hugo because even if I’m confident with no-db-cms (in past I’ve seen something like picocms), this is interestingly new and a lot cooler.
And because I’ve been suggested to give this a try by Madeddu and TeckPerry, two my great former collegues
And because I’m really interested in trying this approach to a whole new level of performances.
Is it possible to build an entire webapp with this paradigm? I honestly do not know, but I’ll probably try to find out
How I made this?
- I followed the Getting started official Guide
- I played a bit with the code/themes/customizations
- I renewed my old AWS Account
- I created a S3 bucket
- I created a github action so that every deploy builds this website
So this is the final schema of the blog
What about the Github Action?
Once you get inside the logic of the github actions, this is pretty self explanatory.
On each push made on master
branch
- Checkout
- Setup hugo using paceiris action
- Build hugo
- Deploy on AWS S3 with jakejarvis action
And that’s it.
name: Deploy to S3
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Hugo
uses: peaceiris/[email protected]
- name: Build
run: hugo --minify
- name: Deploy 🚀
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: 'public' # optional: defaults to entire repository
And now what?
I’m still struggling a bit with AWS ACM since seems like I missed something with the certificate (that’s why I’m still using http
instead of https
) but I’ll fix it. One day.
Update: October 2021
I discovered that the issue is between the old registrartophost
andAWS
, seems like I migrated the domain but not everything got properly migrated. WTF!
There’s More: deploying on FTP
Using all the same stuff, Just changing the final part of the deploy, with this snipped
- name: 📂 Sync files via FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: 'public/'
server-dir: '/htdocs/'