-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.sh
executable file
·41 lines (34 loc) · 953 Bytes
/
bot.sh
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
38
39
40
41
#!/bin/bash
#default configuration
framework='yii'
gitAlias='origin'
branch='master'
#seting configuration from command line
for i in "$@"
do
case $i in
-f=*|--framework=*) framework="${i#*=}" ;;
-a=*|--alias=*) gitAlias="${i#*=}" ;;
-b=*|--branch=*) branch="${i#*=}" ;;
esac
done
#downloading form repo
git pull $gitAlias $branch
#selecting migration command
case "$framework" in
"yii" ) migrate=`php yii migrate --interactive=0` ;;
"symfony" ) migrate=`./symfony doctrine:migrate` ;;
"laravel" ) migrate=`php artisan migrate --force` ;;
*) echo "You must set your framework!!" exit
esac
#last commit message
commit=`git log -1 --pretty=%B`
#create array from last commit
IFS=';' read -r -a command <<< "$commit"
#run command from commit
case "${command[-1]}" in
"composer") composer update ;;
"migrate") $migrate ;;
"all") composer update && $migrate;;
*) echo "Every thing is done."
esac