commit 127c09710f547a70c4f6070283f904ee20eff011
parent 5adcc98367fa42787a770404df57a8dd4d61f854
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date: Wed, 25 Nov 2020 00:17:46 +0100
Add webhook to public repos
Diffstat:
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/make-private b/make-private
@@ -16,6 +16,10 @@ web="/srv/git/html/$(basename "$dir" ".git")"
[ ! -f "$dir/git-daemon-export-ok" ] && echo "$dir is already private." && exit
rm "$dir/git-daemon-export-ok"
+git -C "$dir" remote remove srht
+git -C "$dir" remote remove github
+rm "$dir/hooks/post-update"
+
rm -rf "$web"
repos=""
diff --git a/make-public b/make-public
@@ -16,6 +16,10 @@ dir=$(echo "$1" | sed 's/\.git$\|$/.git/i')
[ -f "$dir/git-daemon-export-ok" ] && echo "$dir is already public." && exit
touch "$dir/git-daemon-export-ok"
+git -C "$dir" remote add srht "git@git.sr.ht:~ob/$(basename "$dir" ".git")"
+git -C "$dir" remote add github "git@github.com:oscarbenedito/$(basename "$dir")"
+ln -sf "$HOME/git-shell-commands/subscripts/post-update-public-repos" "$dir/hooks/post-update"
+
git -C "$dir" update-server-info
mkdir -p "$webdir" || exit 1
diff --git a/subscripts/post-update-public-repos b/subscripts/post-update-public-repos
@@ -0,0 +1,10 @@
+#!/bin/sh
+# TODO make sure you put the correct token.
+
+git update-server-info
+
+dir="$(basename "$(basename "$(pwd)")" ".git")"
+curl -X POST -H "Content-Type: application/json" \
+ -d "{ \"c\": \"token\", \"r\": \"$dir\" }" \
+ "http://localhost:9090/hooks/mirror-repo" \
+ >/dev/null 2>/dev/null