summaryrefslogtreecommitdiff
path: root/leap-repo-updated
blob: 6935e19a84a198f3795d45e5cd6fcb35ba752573 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

leap_cli_updated() {
  # only test on develop for now
  cfg='/etc/leap/rewire_develop.cfg' 
}

leap_platform_updated() {
  case $branch in
    'master') cfg='/etc/leap/rewire_master.cfg' ;;
    'develop') cfg='/etc/leap/rewire_develop.cfg' ;;
    'test_ci') cfg='/etc/leap/rewire_develop.cfg' ;;
    *) echo "Branch $branch not recognized. exiting."; exit 1;;
  esac
}


LOG='/var/log/leap/leap-repo-updated.log'

repo=$1
# example of $2: "refs/heads/test_ci"
branch=`echo $2 |  cut -d'/' -f 3`

case "$repo" in 
  'leap_platform') leap_platform_updated;;
  'leap_cli') leap_cli_updated;;
  *) echo "Repo $repo not recognized. exiting."; exit 1;;
esac

cmd="/usr/local/bin/platform_test/leap-platform-test -c $cfg --all reset_deploy"

echo  "`date`: Branch \"$branch\" in repo \"$repo\" was updated" >> $LOG

name="leap-platform-test-`date +'%F-%H%M%S'`"
echo "Running this cmd in a detatched screen session named $name: $cmd" | tee -a $LOG
screen -s /bin/bash -S $name -d -m $cmd