aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-11-29 01:18:47 -0300
committerEuAndreh <eu@euandre.org>2020-11-29 01:30:36 -0300
commit2f13799914bb85e7537a5c23939291edd455c3c2 (patch)
treea63e366b3045c5bfba97636fcc59cf0d85f9da8d
parentvps.scm: WIP setup cgit (diff)
downloadtoph-2f13799914bb85e7537a5c23939291edd455c3c2.tar.gz
toph-2f13799914bb85e7537a5c23939291edd455c3c2.tar.xz
Add scripts/ci-build.sh
-rwxr-xr-xscripts/ci-build.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/ci-build.sh b/scripts/ci-build.sh
new file mode 100755
index 0000000..67bb59d
--- /dev/null
+++ b/scripts/ci-build.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+set -x
+
+read -r _ SHA _ # oldrev newrev refname
+LOGFILE="/data/static/ci-logs/vps/$(date -Is)-$SHA.log"
+mkdir -p "$(dirname "$LOGFILE")"
+exec &> >(tee -a "$LOGFILE")
+
+echo "Starting CI job at: $(date -Is)"
+
+finish() {
+ STATUS="$?"
+ printf "\n\n>>> exit status was %s\n" "$STATUS"
+ echo "Finishing CI job at: $(date -Is)"
+ popd
+ NOTE=$(cat <<EOF
+See CI logs with:
+ git notes --ref=refs/notes/ci-logs show $SHA
+ git notes --ref=refs/notes/ci-data show $SHA
+EOF
+)
+ git notes --ref=refs/notes/ci-data add -f -m "$STATUS $LOGFILE"
+ git notes --ref=refs/notes/ci-logs add -f -F "$LOGFILE"
+ git notes add -f -m "$NOTE"
+ printf "\n\n>>> CI logs added as Git note."
+}
+trap finish EXIT
+
+unset GIT_DIR
+CLONE="$(mktemp -d)"
+git clone . "$CLONE"
+pushd "$CLONE"
+git config --global user.email git@euandre.org
+git config --global user.name 'EuAndreh CI'
+
+./container make check site
+./container make publish