bajsicki.com/README.org

44 lines
1.7 KiB
Org Mode
Raw 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.
2024-11-18 15:44:17 +01:00
export GIT_WORK_TREE=/srv/bajsicki.com/
2024-11-18 19:14:32 +01:00
cd $GIT_WORK_TREE
echo "post-receive: Generating https://bajsicki.com with Hugo in $(pwd)"
2024-09-27 15:29:50 +02:00
# Remove any files already in the public directory, a fresh copy will be generated by hugo
2024-11-18 19:14:32 +01:00
echo "post-receive: Cleaning the /public and /content directory to ensure we're in line."
rm -rf public/ && echo "removing /public in $(pwd)"
rm -rf content/ && echo "removing /content in $(pwd)"
2024-11-18 15:44:17 +01:00
# Update the modules in case of changes and pull the new pages
2024-11-18 19:14:32 +01:00
echo "post-receive: pulling git repo and submodules in $(pwd) w/ subshell"
(
unset $(env | sed -ne 's/^\(GIT_.*\)=.*/\1/p')
cd /srv/bajsicki.com
git pull origin main --recurse-submodules --force
)
2024-09-27 15:29:50 +02:00
# Generate the site with hugo
2024-11-18 19:14:32 +01:00
echo "post-receive: running hugo in $(pwd)"
hugo
2024-09-27 15:29:50 +02:00
# Fix any permission problems.
2024-11-18 19:14:32 +01:00
echo "post-receive: fixing permissions in $(pwd)"
find public -type f -print | xargs -d '\n' chmod 644
find public -type d -print | xargs -d '\n' chmod 755
2024-09-27 15:29:50 +02:00
2024-11-18 19:14:32 +01:00
echo "post-receive: Hugo site deployment in $(pwd) complete"
2024-09-28 01:26:46 +02:00
#+end_src
2024-11-18 15:44:17 +01:00