summaryrefslogtreecommitdiff
path: root/examples/olamic-githook-post-receive
blob: 3135d0df5bf4a0074a407f316d4fffee5e96f02e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

set -eu

OLAMIC_QUEUE_HOST="${OLAMIC_QUEUE_HOST:-}"
OLAMIC_QUEUE_DIR="${OLAMIC_QUEUE_DIR:-/srv/olamic/queue}"
OLAMIC_GIT_REPO="${OLAMIC_GIT_REPO:-"$(git rev-parse --absolute-git-dir)"}"

while read OLD NEW REF; do
    if git rev-parse --quiet --verify "$NEW":olamic-run > /dev/null; then
        OLAMIC_EMAIL="$(git show --no-patch --format=%ae "$NEW")"
        echo -n "Enqueuing olamic run for $REF: "
        if [[ "$OLAMIC_QUEUE_HOST" == "" ]]; then
            olamic-enqueue "$OLAMIC_QUEUE_DIR" "$OLAMIC_GIT_REPO" "$NEW" GIT_REF="$REF" OLAMIC_EMAIL="$OLAMIC_EMAIL" <<END
. ./olamic-run
END
        else
            ssh "$OLAMIC_QUEUE_HOST" olamic-enqueue "$OLAMIC_QUEUE_DIR" "$OLAMIC_GIT_REPO" "$NEW" GIT_REF="$REF" OLAMIC_EMAIL="$OLAMIC_EMAIL" <<END
. ./olamic-run
END
        fi
    fi
done