diff --git a/.githooks/post-commit b/.githooks/post-commit new file mode 100755 index 00000000..b57fc6ab --- /dev/null +++ b/.githooks/post-commit @@ -0,0 +1,38 @@ +#!/bin/bash + +set -u + +REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" +SCRIPT_PATH="$REPO_ROOT/scripts/release/pre_release_web.sh" +LOG_FILE="$REPO_ROOT/logs/post-commit.log" +COMMIT_HASH="$(git rev-parse --short HEAD 2>/dev/null || echo unknown)" + +mkdir -p "$(dirname "$LOG_FILE")" + +{ + echo "" + echo "=== post-commit @ $(date +%Y-%m-%dT%H:%M:%S%z) ===" + echo "repo: $REPO_ROOT" + echo "commit: $COMMIT_HASH" + echo "script: $SCRIPT_PATH" + echo "" +} >> "$LOG_FILE" + +if [ ! -x "$SCRIPT_PATH" ]; then + { + echo "=== ERROR: script not executable or not found ===" + echo "path: $SCRIPT_PATH" + echo "=== post-commit EXIT_CODE=127 @ $(date +%Y-%m-%dT%H:%M:%S%z) ===" + } >> "$LOG_FILE" + exit 127 +fi + +"$SCRIPT_PATH" >> "$LOG_FILE" 2>&1 +EXIT_CODE=$? + +{ + echo "" + echo "=== post-commit EXIT_CODE=$EXIT_CODE @ $(date +%Y-%m-%dT%H:%M:%S%z) ===" +} >> "$LOG_FILE" + +exit "$EXIT_CODE"