list

scripts

Repo containing scripts to be used with dovel, and git hooks that powers our web interface.

curl https://dovel.email/scripts.tar tar

6fd0665

Author: brian (git@myr.sh)

Date: Mon Sep 18 23:28:34 2023 -0300

Parent: 183653c

Added git hook

Diff

diff --git a/post-receive b/post-receive
new file mode 100755
index 0000000..52a8911
--- /dev/null
+++ b/post-receive
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+#for debugging
+#set -ex
+
+# the work tree, where the checkout/deploy should happen
+TGT="$(mktemp)"
+OUT="~/www/dovel.email/"
+GITDIR="~/dovel.email/"
+
+# git.html lists all repos
+cat << EOF
+<!DOCTYPE html>
+<html>
+<head>
+	<title>dovel's git</title>
+	<meta charset="UTF-8">
+	<meta name="author" content="Brian Lee Mayer">
+	<meta name="description" content="This is the development homepage of the Dovel project. Find here all repos mailing lists. And latest development changes.">
+	<meta name="language" content="english">
+	<meta name="keywords" content="email, dovel, blmayer, self host, software, smtp, web, interface">
+	<meta name="viewport" content="width=device-width, initial-scale=1">
+	<meta name="color-scheme" content="light dark">
+	<style>
+	body {
+		max-width: 600px;
+		margin: 60px auto;
+		padding: 20px;
+		font-family: sans-serif;
+	}
+	pre {
+		font-weight: bold;
+		background: lightgray;
+		padding: 8px;
+		border-radius: 8px;
+	}
+	ol li {padding-bottom: 10px}
+	tt {font-weight: bold}
+	@media (prefers-color-scheme: dark) {
+		pre {background: darkslategray}
+	}
+	</style>
+</head>
+<body>
+	<h1>Repositories</h1>
+	<dl>
+EOF > "$OUT/git.html"
+
+for dir in "$GITDIR"/*
+do
+	{
+		cat <<- EOF
+		<dt>$dir</dt>
+		<dd>"$(cat "$dir/.git/description")</dd>
+		<dd>Last commit
+		EOF
+		git --git-dir "$dir/.git/" log -n 1 --format="%h at %ah"
+		echo "</dd>"
+	}  >> "$OUT/git.html"
+done
+
+cat << EOF
+	</dl>
+</body>
+</html>
+EOF
+
+# the location of the .git directory
+GIT_DIR="/home/blmayer/git/site"
+
+# create commit pages
+while read oldrev newrev ref
+do
+        # only checking out the master (or whatever branch you would like to deploy)
+        if [ "$ref" = "refs/heads/$BRANCH" ]
+        then
+                git --work-tree="/home/blmayer/www/myr.sh" --git-dir="${GIT_DIR}" checkout -f ${BRANCH}
+        else
+                echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
+        fi
+done
+