bajsicki.com/README.org

51 lines
1.6 KiB
Org Mode
Raw Permalink Normal View History

2024-09-26 11:11:01 +02:00
#+title: Bajsicki.com
This is the git for my personal website. Nothing to see here, just pretty vanilla hugo stuff.
2024-09-27 15:29:50 +02:00
* Deployment
2024-09-28 01:26:46 +02:00
I'm using a git hook to automatically purge and re-build the ~/public~ directory after each commit. I don't get enough traffic for this to be an inconvenience.
2024-09-27 15:29:50 +02:00
2024-09-28 01:26:46 +02:00
I used some of [[https://jasonmurray.org/posts/2020/githugogen/][this article]] by Jason Murray to help me understand how git hooks work. I'm running [[https://forgejo.org/][Forgejo]], and this is a much more elegant and simple solution when compared to running Actions or other CI/CD tools.
2024-09-27 15:29:50 +02:00
2024-09-28 01:26:46 +02:00
The post-receive hook is like so:
#+begin_src sh
2024-09-27 15:29:50 +02:00
#!/bin/bash
# Directory on the server where the website will be mapped.
export GIT_WORK_TREE=/srv/bajsicki.com
echo `pwd`
echo "post-receive: Generating https://bajsicki.com with Hugo..."
# Create the directory and all subdirectories if they don't exist.
mkdir -p $GIT_WORK_TREE
chmod 755 $GIT_WORK_TREE
# Remove any files already in the public directory, a fresh copy will be generated by hugo
rm -rf $GIT_WORK_TREE/public
# Generate the site with hugo
2024-09-28 01:33:01 +02:00
cd $GIT_WORK_TREE && chmod +x update.sh
2024-09-28 01:26:46 +02:00
cd $GIT_WORK_TREE && ./update.sh
2024-09-27 15:29:50 +02:00
# Fix any permission problems.
find $GIT_WORK_TREE/public -type f -print | xargs -d '\n' chmod 644
find $GIT_WORK_TREE/public -type d -print | xargs -d '\n' chmod 755
echo "post-receive: Hugo site generation complete"
#+end_src
2024-09-28 01:26:46 +02:00
The ~update.sh~ script is as dead simple as things get.
#+begin_src sh
#!/usr/bin/env sh
cd themes/hugo-tufte/
git reset --hard && git pull origin main -f
cd ../..
git reset --hard && git pull origin main -f
hugo
#+end_src