41 lines
1.4 KiB
Bash
41 lines
1.4 KiB
Bash
{% if pillar['laradev'] is defined %}
|
|
{%- for project in pillar['laradev'] %}
|
|
{%- set repo = pillar['laradev'][project]['repo'] %}
|
|
#{{project}}
|
|
mkdir -p "/sites/{{project}}"
|
|
cd "/sites/{{project}}"
|
|
branches=`git ls-remote {{repo}} | grep -o -P "(?<=refs/heads/).*"`
|
|
echo "Branches:<br/>" > /sites/{{project}}/index.php
|
|
for branch in $branches; do
|
|
echo " <a href='$branch/public'>$branch<br/>" >> /sites/{{project}}/index.php
|
|
#clone new branch if necessary
|
|
if [ ! -d "$branch" ];then
|
|
git clone -b $branch {{repo}} "$branch"
|
|
chown http:http -R "$branch"
|
|
cd "$branch"
|
|
su -s /bin/bash http -c "composer install"
|
|
cp .env.example .env
|
|
mysql -u root -e "CREATE DATABASE laradev_{{project}}_$branch"
|
|
mysql -u root -e "GRANT ALL ON laradev_{{project}}_$branch.* TO laradev@localhost"
|
|
sed -i "s/DB_DATABASE=homestead/DB_DATABASE=laradev_{{project}}_$branch/" .env
|
|
sed -i "s/DB_USERNAME=homestead/DB_USERNAME=laradev/" .env
|
|
php artisan key:generate
|
|
php artisan migrate
|
|
php artisan db:seed
|
|
php artisan vendor:publish
|
|
php artisan storage:link
|
|
cd "/sites/{{project}}"
|
|
fi
|
|
#update to latest commit, dropping all local changes
|
|
cd "$branch"
|
|
git fetch --all
|
|
git reset --hard origin/$branch
|
|
chown http:http -R "$branch"
|
|
su -s /bin/bash http -c "composer install"
|
|
php artisan migrate
|
|
cd "/sites/{{project}}"
|
|
chown http:http -R "$branch"
|
|
done
|
|
chown http:http "/sites/{{project}}" -R
|
|
{%- endfor -%}
|
|
{% endif %}
|