31 lines
1.2 KiB
Bash
31 lines
1.2 KiB
Bash
mkdir -p "/usr/share/webapps/laradev"
|
|
chown http:http /srv/http
|
|
{% if pillar['laradev'] is defined %}
|
|
{%- for project in pillar['laradev'] %}
|
|
{%- set repo = pillar['laradev'][project]['repo'] -%}
|
|
{%- set path = pillar['laradev'][project]['path'] -%}
|
|
{%- set prefix = pillar['laradev'][project]['prefix'] -%}
|
|
mkdir -p "{{ path }}"
|
|
branches=`git ls-remote {{repo}} | grep -o -P "(?<=refs/heads/).*"`
|
|
for branch in $branches; do
|
|
#clone new branch if necessary
|
|
if [ ! -d "{{path}}/$branch" ];then
|
|
git clone -b $branch {{ repo }} "{{path}}/$branch"
|
|
ln -s "{{path}}/$branch/public" "/usr/share/webapps/laradev/{{prefix}}$branch"
|
|
chown http:http -R "{{path}}/$branch"
|
|
cd "{{path}}/$branch"
|
|
su -s /bin/bash http -c "composer install"
|
|
cp .env.example .env
|
|
sed -i "s/DB_DATABASE=homestead/DB_DATABASE=laradev_$prefix$branch/" .env
|
|
sed -i "s/DB_USERNAME=homestead/DB_USERNAME=laradev/" .env
|
|
php artisan key:generate
|
|
fi
|
|
#update to latest commit, dropping all local changes
|
|
cd "{{path}}/$branch"
|
|
git fetch --all
|
|
git reset --hard origin/$branch
|
|
php artisan migrate
|
|
chown http:http -R "{{path}}/$branch"
|
|
done
|
|
{%- endfor -%}
|
|
{% endif %}
|