@@ -0,0 +1,59 @@
+#!/bin/bash
+set -euo pipefail
+
+GIT_DIR="$(git rev-parse --git-dir 2>/dev/null || echo .)"
+
+# try to get pusher info from environment (SSH/HTTP vary)
+PUSHER="${GIT_AUTHOR_NAME:-${USER:-unknown}}"
+PUSHER_EMAIL="${GIT_AUTHOR_EMAIL:-}"
+
+timestamp() { date -u +"%Y-%m-%dT%H:%M:%SZ"; }
+
+while read -r old new ref; do
+ # determine ref type
+ if [[ "$ref" == refs/heads/* ]]; then
+ ref_type="branch"
+ ref_name="${ref#refs/heads/}"
+ elif [[ "$ref" == refs/tags/* ]]; then
+ ref_type="tag"
+ ref_name="${ref#refs/tags/}"
+ else
+ ref_type="other"
+ ref_name="$ref"
+ fi
+
+ # commit info (may be empty on deletes where new == 0000000...)
+ if [[ "$new" =~ ^0+$ ]]; then
+ commit_sha=""
+ else
+ commit_sha="$new"
+ fi
+
+ # collect more details where available
+ repo_path="$(pwd)"
+ repo_name="$(basename "$repo_path" .git)"
+ org_name="$(basename "$(dirname "$repo_path")")"
+ pusher_ip="${SSH_CONNECTION%% *}" || pusher_ip=""
+
+ payload_args=(
+ "--repo" "$org_name/$repo_name"
+ "--ref" "$ref"
+ "--ref-type" "$ref_type"
+ "--ref-name" "$ref_name"
+ "--old" "$old"
+ "--new" "$new"
+ "--commit" "$commit_sha"
+ "--pusher" "$PUSHER"
+ "--pusher-email" "$PUSHER_EMAIL"
+ "--pusher-ip" "$pusher_ip"
+ "--git-dir" "$GIT_DIR"
+ "--timestamp" "$(timestamp)"
+ )
+
+ # call asynchronously so push isn't blocked
+ echo "gitfoss-ci-runner trigger \"${payload_args[@]}\"\n"
+ echo "gitfoss-ci-runner trigger \"${payload_args[@]}\"\n" >> /var/log/gitfoss/ci.log
+ /usr/bin/gitfoss-ci-runner trigger "${payload_args[@]}";
+done
+
+exit 0