From dddb2cbd60b156803ab4e189fa03e4e503311d53 Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Sun, 2 Jun 2024 14:05:40 -0400 Subject: [PATCH] switch to post-receive hook for CI --- .gitignore | 1 + hooks/post-receive | 26 ++++++++++++++++++++++++++ hooks/pre-push | 2 -- readme.md | 9 ++++++--- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100755 hooks/post-receive delete mode 100755 hooks/pre-push diff --git a/.gitignore b/.gitignore index 9b98613..0de82ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .pub +production.env diff --git a/hooks/post-receive b/hooks/post-receive new file mode 100755 index 0000000..02c6a49 --- /dev/null +++ b/hooks/post-receive @@ -0,0 +1,26 @@ +#!/bin/bash +set -e -u + +while read oldrev newrev ref +do + if [[ $ref =~ .*/main$ ]]; then + echo "main ref received" + + echo "moving into temporary work tree"; { + gitdir=$PWD + cd ~/jonathan.is + } + + echo "checking out latest source"; { + git --work-tree=$PWD --git-dir=$gitdir checkout --force + } + + echo "building and deploying site"; { + podman-compose --profile deploy build + } + + echo "updating post-receive hook for future runs"; { + cp hooks/post-receive $0 + } + fi +done diff --git a/hooks/pre-push b/hooks/pre-push deleted file mode 100755 index 4ec61ae..0000000 --- a/hooks/pre-push +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -neocities push .pub diff --git a/readme.md b/readme.md index 1fc6f44..e7274d9 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,9 @@ ## quickstart -## manual install +develop + + zs serve --debug build @@ -11,9 +13,10 @@ build run podman compose up -deploy - podman compose --profile deploy up deploy +deploy - runs a post-receive hook on the remote which pushes to neocities + + git push ## todo