diff options
author | Elizabeth Alexander Hunt <me@liz.coffee> | 2025-05-10 16:57:03 -0700 |
---|---|---|
committer | Elizabeth Alexander Hunt <me@liz.coffee> | 2025-05-10 16:57:03 -0700 |
commit | fa8f3f9465e87d499f7d6428323f496a884b7818 (patch) | |
tree | ab477dfa52ef30282029c4f136bf605cb24d67a9 /worker/jobs/checkout_ci.run | |
download | ci-fa8f3f9465e87d499f7d6428323f496a884b7818.tar.gz ci-fa8f3f9465e87d499f7d6428323f496a884b7818.zip |
initial commit
Diffstat (limited to 'worker/jobs/checkout_ci.run')
-rw-r--r-- | worker/jobs/checkout_ci.run | 39 |
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 |