summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/olamic-githook-post-receive23
-rw-r--r--examples/olamic-run25
2 files changed, 48 insertions, 0 deletions
diff --git a/examples/olamic-githook-post-receive b/examples/olamic-githook-post-receive
new file mode 100755
index 0000000..3135d0d
--- /dev/null
+++ b/examples/olamic-githook-post-receive
@@ -0,0 +1,23 @@
1#!/bin/bash
2
3set -eu
4
5OLAMIC_QUEUE_HOST="${OLAMIC_QUEUE_HOST:-}"
6OLAMIC_QUEUE_DIR="${OLAMIC_QUEUE_DIR:-/srv/olamic/queue}"
7OLAMIC_GIT_REPO="${OLAMIC_GIT_REPO:-"$(git rev-parse --absolute-git-dir)"}"
8
9while read OLD NEW REF; do
10 if git rev-parse --quiet --verify "$NEW":olamic-run > /dev/null; then
11 OLAMIC_EMAIL="$(git show --no-patch --format=%ae "$NEW")"
12 echo -n "Enqueuing olamic run for $REF: "
13 if [[ "$OLAMIC_QUEUE_HOST" == "" ]]; then
14 olamic-enqueue "$OLAMIC_QUEUE_DIR" "$OLAMIC_GIT_REPO" "$NEW" GIT_REF="$REF" OLAMIC_EMAIL="$OLAMIC_EMAIL" <<END
15. ./olamic-run
16END
17 else
18 ssh "$OLAMIC_QUEUE_HOST" olamic-enqueue "$OLAMIC_QUEUE_DIR" "$OLAMIC_GIT_REPO" "$NEW" GIT_REF="$REF" OLAMIC_EMAIL="$OLAMIC_EMAIL" <<END
19. ./olamic-run
20END
21 fi
22 fi
23done
diff --git a/examples/olamic-run b/examples/olamic-run
new file mode 100644
index 0000000..eebcfb5
--- /dev/null
+++ b/examples/olamic-run
@@ -0,0 +1,25 @@
1# vim: set ft=bash :
2
3# This is an example olamic-run script for a "typical" app
4# Olamic scripts are run under /bin/bash with "set -eux -o pipefail" in effect
5
6# Variables provided by olamic
7# GIT_OBJECT The git commit that was cloned
8# GIT_REF The ref that triggered this run (post-receive hook)
9# GIT_REPO The path to the git repo
10# TASK_ID UUID for this olamic run
11
12make
13make test
14
15if [[ $GIT_REF =~ ^refs/tags/(.+)$ ]]; then
16 INSTALL_DIR=/srv/app/tag/"${BASH_REMATCH[1]}"
17elif [[ $GIT_REF =~ ^refs/heads/(.+)$ ]]; then
18 INSTALL_DIR=/srv/app/branch/"${BASH_REMATCH[1]}"
19fi
20
21if [[ "${INSTALL_DIR:-}" != "" ]]; then
22 rm -rf "$INSTALL_DIR"
23 mkdir -p "$INSTALL_DIR"
24 make install PREFIX="$INSTALL_DIR"
25fi