You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
931 B
Fish
53 lines
931 B
Fish
#!/usr/bin/env fish
|
|
# called using shellsrv git-build <repo url>
|
|
|
|
set -l repo $argv[1]
|
|
set -l path $argv[3]
|
|
set -l local_location (pwd)
|
|
|
|
if test "$path" != '/build-pls'
|
|
echo "invalid path"
|
|
exit 1
|
|
end
|
|
|
|
set -l tmp_dir /tmp/build_(random)
|
|
|
|
git clone $repo $tmp_dir
|
|
cd $tmp_dir
|
|
|
|
# read json from stding - which is the request body
|
|
git checkout (jq -r '.after')
|
|
|
|
# read config
|
|
set mount /pipeline
|
|
set envfile ""
|
|
|
|
for l in (cat .ezpipe)
|
|
if test -z "$l"
|
|
continue
|
|
end
|
|
set -l parts (string split -m 1 "=" "$l")
|
|
set $parts[1] $parts[2]
|
|
end
|
|
|
|
set docker_args
|
|
|
|
if test -z "$image"
|
|
echo "image required"
|
|
exit 1
|
|
end
|
|
if test -z "$entrypoint"
|
|
echo "entrypoint required"
|
|
exit 1
|
|
end
|
|
|
|
if test ! -z "$envfile"
|
|
set -a docker_args '--env-file'
|
|
set -a docker_args $local_location/$envfile
|
|
end
|
|
|
|
docker run --rm $docker_args -v (pwd):$mount -w $mount $image $mount/$entrypoint
|
|
|
|
cd ..
|
|
rm -rf $tmp_dir
|