summaryrefslogtreecommitdiff
path: root/worker/jobs/checkout_ci.run
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2025-05-10 16:57:03 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2025-05-10 16:57:03 -0700
commitfa8f3f9465e87d499f7d6428323f496a884b7818 (patch)
treeab477dfa52ef30282029c4f136bf605cb24d67a9 /worker/jobs/checkout_ci.run
downloadci-fa8f3f9465e87d499f7d6428323f496a884b7818.tar.gz
ci-fa8f3f9465e87d499f7d6428323f496a884b7818.zip
initial commit
Diffstat (limited to 'worker/jobs/checkout_ci.run')
-rw-r--r--worker/jobs/checkout_ci.run39
1 files changed, 39 insertions, 0 deletions
diff --git a/worker/jobs/checkout_ci.run b/worker/jobs/checkout_ci.run
new file mode 100644
index 0000000..d47697d
--- /dev/null
+++ b/worker/jobs/checkout_ci.run
@@ -0,0 +1,39 @@
+#!/bin/bash
+# usage: laminarc run ci remote="ssh://src.liz.coffee:2222/cgit" rev="<sha>" \
+# refname="refs/..."
+
+set -e
+
+RUN=`date +%s`
+WORKING_DIR=`$PWD/$RUN`
+
+mkdir -p "$WORKING_DIR" && cd "$WORKING_DIR"
+
+checkout="$rev" path="tmpsrc" fetch_code.sh
+
+if [[ ! -e "$WORKING_DIR/tmpsrc/.ci/ci.json" ]]; then
+ echo "No Continuous Integration configured for $remote."
+ exit 0
+fi
+
+PIPELINE_GENERATOR_PATH=$(jq -r '.pipeline' "$WORKING_DIR/tmpsrc/.ci/ci.json")
+if [[ "$PIPELINE_GENERATOR_PATH" == *".."* ]]; then
+ echo "Error: Path contains '..'"
+ exit 1
+fi
+
+docker run --rm \
+ --network none \
+ --cap-drop ALL \
+ --security-opt no-new-privileges \
+ -v "$WORKING_DIR/tmpsrc/$PIPELINE_GENERATOR:/pipeline" \
+ -e refname="$refname" \
+ -e rev="$rev" \
+ -e remote="$remote" \
+ oci.liz.coffee/img/liz-ci:release \
+ /pipeline \
+ > "$WORKING_DIR/pipeline.json"
+
+rm -rf tmpsrc
+
+pipeline="$WORKING_DIR/pipeline.json" run_pipeline