Currently Link to heading
Currently I'm deploying hugo with a rather mediorce BASH script which syncs data to a directory on my VPS. This process has a few issues:
- The site is only updated manually (e.g. I can't exactly "schedule" posts unless I write things and then upload when I want them to go live)
- I wasn't properly running Hugo or rsync with my deployment
- For
hugo
,--cleanDestinationDir
was important as I had old pages I didn't want to exist persisting online - For
rsync
,--delete
so the things I was removing from my site actually got removed on the server
- For
Improving Link to heading
I need my deployment solution to:
- Ingest my bands list to create my gig archives
- Regularly check for updates to the site (via Git repos)
- Allows me to write drafts and work on new structures without much extra manual work for keeping deployments working properly
The Hugo documentation only seems to cover manual deployments. Other articles out on the web seem to use platform-specific pipelines (e.g. GitHub actions) to trigger site builds but that seems too "fancy" for my brain. I just want to incrementally build the site.
What I've Done Link to heading
- Allowed VPS access to GitHub repository with a read-only Deploy Key
- Cloned the private repository to a non-public location on the VPS
git clone git@github.com:ColonelPanicks/stuts.uk.git /opt/stuts.uk cd /opt/stuts.uk git submodule update --init
- Created copy of existing site structure (backups are important)
- Created a script to do useful bits for me
- Setup crontab to run hugo compile command during witching hours
0 3 * * * bash /opt/deploy_stuts.sh >> /var/log/stuts_deploy.log
The script itself is fairly simple, see below (with bits doing my bands list ingestion and parsing removed as that's probably worth an article in itself!)
# Ensure up-to-date
echo "# Updating git repo"
cd /opt/stuts.uk
git reset --hard # because bands list changes could cause merge conflicts when Stu actually commits updates
git pull
git submodule update
# Render site to publicly-accessible directory
echo "# Updating live website"
hugo --cleanDestinationDir -d /var/www/stuts.uk
chown -R nginx: /var/www/stuts.uk
The Outcome Link to heading
I'm hoping the outcome prevents me from sucking at blogging as much as I do. Taking bets on whether that's the case or if I just enjoy tinkering over writing...