commit 8763b7faf213f9bc64840a48fbd94adb3024ac75 Author: davidontop Date: Mon Aug 12 16:26:09 2024 +0200 Initial commit diff --git a/.git_hooks/post-receive b/.git_hooks/post-receive new file mode 100755 index 0000000..4588ff7 --- /dev/null +++ b/.git_hooks/post-receive @@ -0,0 +1,16 @@ +#!/bin/bash + +RP="${PWD#/srv/git/}" + +while read oldrev newrev ref +do + # Check if the ref is a tag and if it's a new tag + if [[ $ref == refs/tags/* ]] + then + echo "New tag detected: $ref" + echo "Sending cicd tag webhook" + curl -s -o /dev/null -w "" https://n8n.davidon.top/webhook/git/tag/$RP/$BRANCH + echo "Sent cicd tag webhook" + fi +done + diff --git a/.git_hooks/post-update b/.git_hooks/post-update new file mode 100755 index 0000000..881c5d1 --- /dev/null +++ b/.git_hooks/post-update @@ -0,0 +1,13 @@ +#!/bin/bash + +BRANCH=$(git rev-parse --symbolic --abbrev-ref $1) +RP="${PWD#/srv/git/}" + +echo "Creating minio backup." +git bundle create repo.bundle --all +mcli mv "$PWD/repo.bundle" "hs/git/$PWD/repo.bundle" +echo "Repository $RP backed up to minio." + +echo "Sending cicd push webhook" +curl -s -o /dev/null -w "" https://n8n.davidon.top/webhook/git/push/$RP/$BRANCH +echo "Sent cicd push webhook" diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..ed4d5db --- /dev/null +++ b/.gitconfig @@ -0,0 +1,4 @@ +[core] + hooksPath = /srv/git/.git_hooks/ +[init] + defaultBranch = main diff --git a/git-shell-commands/configure b/git-shell-commands/configure new file mode 100755 index 0000000..9b29b56 --- /dev/null +++ b/git-shell-commands/configure @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ "$#" -ne 3 ]; then + echo "Usage: configure " + exit 1 +fi + +echo "Enter description: " +read INPUT + +REPO_PATH="/srv/git/$1" +cd "$REPO_PATH" && git config --local "$2" "$3" +echo "Wrote '$INPUT' into $REPO_PATH/description" diff --git a/git-shell-commands/create b/git-shell-commands/create new file mode 100755 index 0000000..fb2b849 --- /dev/null +++ b/git-shell-commands/create @@ -0,0 +1,10 @@ +#!/bin/bash +if [ "$#" -ne 1 ]; then + echo "Usage: create " + exit 1 +fi + +REPO_PATH="/srv/git/$1" +mkdir -p "$REPO_PATH" +cd "$REPO_PATH" && git init --bare +echo "New bare git repo created at $REPO_PATH" diff --git a/git-shell-commands/create-hidden b/git-shell-commands/create-hidden new file mode 100755 index 0000000..8cc2ce1 --- /dev/null +++ b/git-shell-commands/create-hidden @@ -0,0 +1,10 @@ +#!/bin/bash +if [ "$#" -ne 1 ]; then + echo "Usage: create-hidden " + exit 1 +fi + +REPO_PATH="/srv/git/$1" +mkdir -p "$REPO_PATH" +cd "$REPO_PATH" && git init --bare && git config --local cgit.hide 1 +echo "New bare hidden git repo created at $REPO_PATH" diff --git a/git-shell-commands/describe b/git-shell-commands/describe new file mode 100755 index 0000000..3052028 --- /dev/null +++ b/git-shell-commands/describe @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ "$#" -ne 1 ]; then + echo "Usage: describe " + exit 1 +fi + +echo "Enter description: " +read INPUT + +REPO_PATH="/srv/git/$1" +cd "$REPO_PATH" && echo "$INPUT" > description +echo "Wrote '$INPUT' into $REPO_PATH/description" diff --git a/git-shell-commands/help b/git-shell-commands/help new file mode 100755 index 0000000..ebabe06 --- /dev/null +++ b/git-shell-commands/help @@ -0,0 +1,3 @@ +#!/bin/bash +echo "Available commands:" +ls /srv/git/git-shell-commands diff --git a/git-shell-commands/no-interactive-login b/git-shell-commands/no-interactive-login new file mode 100755 index 0000000..005f67a --- /dev/null +++ b/git-shell-commands/no-interactive-login @@ -0,0 +1,4 @@ +#!/bin/sh +printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not" +printf '%s\n' "provide interactive shell access." +exit 128