git-lfs-test/build/git-post-receive-hook
Tom Willemse 7f1c755c4e Reduce scope of the git hook script
The git hook script should only extract the necessary information the build
script needs to operate. Right now this is only the commit before the push and
after the push, and the refname is added for future use.

The name of the variables passed to the laminar build are modeled after those
found in the GitLab CI documentation, just for some familiarity.

The functionality of finding the relevant directories has been moved to the
build script.
2023-12-16 23:50:11 -08:00

23 lines
758 B
Python
Executable file

#!/usr/bin/env python
from shlex import quote
from subprocess import run
import os
import sys
for line in sys.stdin:
precommit, postcommit, refname = line.strip().split(' ')
if not refname == "refs/heads/main":
print(f"Skipping ref \"{refname}\"")
continue
os.putenv("LAMINAR_REASON", "Push to git repository")
cmd = "laminarc queue freeloadio " \
f"CI_COMMIT_BEFORE_SHA={quote(precommit)} " \
f"CI_COMMIT_SHA={quote(postcommit)} " \
f"CI_COMMIT_REF_NAME={quote(refname)}"
print(cmd)
process = run(cmd, shell=True, capture_output=True)
buildname, buildrun = process.stdout.decode().strip().split(':')
print(f"Queued build: https://laminar.ryuslash.org/jobs/{buildname}/{buildrun}")