🏠 Repo synced with my minimal website
This site is statically powered by Hugo using Minimal Theme and selfhosted with docker on my Raspberry Pi 4. It´s also linked with this repository using GitHub Actions to update the website when it changes.
-
Install Hugo and generate new site
brew install hugo hugo new site <name>
-
Install a theme by cloning its repo to themes/
git submodule add <theme-repo> themes/<theme-name>
-
Tweak config.toml to taste and add more content with:
hugo new content/<name>
-
Run the server with:
hugo server -D
-
Try it with your browser on
localhost:1313
In the host machine first clone your repo with the following command:
git clone --recurse-submodules -j8 <your-repo>
Save this docker-compose file and as optional, add a .env file with the only variable DOMAIN_NAME='yourdomain'. If there's no .env file it will take localhost by default and you should remove the environment lines.
version: '3.0'
services:
web:
image: pruizca/hugo
container_name: personal_website
hostname: website
ports:
- "1313:1313"
volumes:
- ./:/site
environment:
- DOMAIN=${DOMAIN_NAME}
Run docker-compose up
to test it, docker-compose up -d
to keep it in the background if working correctly. The website should be up at localhost:1313
To update the website the process is quite simple:
ssh
to the machine hosting the websitecd
to the website directory- Run
git pull
We can automate this with GitHub Actions saving all sensitive info in the repository secrets (Repository Settings -> Secrets). We need to save the following, each in a secret:
PROJECT_PATH
: path to your website folder in the host machineSERVER_IP
: public IP of your host machineSERVER_PORT
: ssh port opened to access the host machineSERVER_USERNAME
: username of the host machineSERVER_KEY
: private ssh key that has access to the host machine
Then create a new github action and add the following script:
name: CI
on: [push]
jobs:
deploy:
if: github.ref == 'refs/heads/main'
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Push to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
port: ${{ secrets.SERVER_PORT }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_KEY }}
script: cd ${{ secrets.PROJECT_PATH }} && git pull
Now whenever you push the host downloads the new files and the website should update accordingly.