webhooksd/on-push.zsh

28 lines
503 B
Bash
Raw Permalink Normal View History

2020-12-16 00:43:00 +01:00
#!/usr/bin/env zsh
2020-12-20 18:44:42 +01:00
function extract_option {
local file_name="$1"
local option="$2"
2020-12-16 00:43:00 +01:00
2020-12-20 18:44:42 +01:00
sed -n "/^${option}: */{s/^${option}:[ \t]*//;p}" < $file_name
}
2020-12-16 00:43:00 +01:00
2020-12-20 18:44:42 +01:00
PROJECT=$(jq -r '.repository.name' < payload.json)
GIT=$(jq -r '.repository.clone_url' < payload.json)
2020-12-16 00:43:00 +01:00
git clone $GIT
cd $PROJECT
2020-12-20 18:44:42 +01:00
CMD=$(extract_option "hooks_config" "commande")
ENV=$(extract_option "hooks_config" "env")
2020-12-16 00:43:00 +01:00
REV=$(git rev-parse HEAD)
2020-12-20 18:44:42 +01:00
shards install
shards build
/bin/sh -c $CMD | ../tap-aggregator add $PROJECT $ENV $REV
2020-12-16 00:43:00 +01:00
exit 1