Skip to content

Instantly share code, notes, and snippets.

@chrisblackwell
Last active May 5, 2022 22:40

Revisions

  1. chrisblackwell revised this gist Oct 5, 2014. 1 changed file with 3 additions and 10 deletions.
    13 changes: 3 additions & 10 deletions post-receive-for-laravel.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    #!/bin/sh
    WEBROOT=/srv/www/apps.legendboats.com
    GIT_WORK_TREE=$WEBROOT git checkout -f
    #git --work-tree=/srv/www/apps.legendboats.com --git-dir=/srv/repo/apps.legendboats.git checkout -f

    cd $WEBROOT

    @@ -20,19 +19,13 @@ rm -f bootstrap/compiled.php
    rm -f app/storage/meta/services.json

    # install packages, this also regenerates the autoloader
    if [[ $dev ]]; then
    composer install --no-scripts
    else
    composer install --no-scripts --no-dev --no-interaction --prefer-dist
    fi
    composer install --no-scripts --no-dev --no-interaction --prefer-dist

    # display the environment
    php artisan env

    # run any outstanding migrations
    php artisan migrate --force

    if [[ ! $dev ]]; then
    # optimize autoloader and compile common classes
    php artisan optimize --force
    fi
    # optimize autoloader and compile common classes
    php artisan optimize --force
  2. chrisblackwell renamed this gist Oct 5, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. chrisblackwell created this gist Oct 5, 2014.
    38 changes: 38 additions & 0 deletions post-receive
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #!/bin/sh
    WEBROOT=/srv/www/apps.legendboats.com
    GIT_WORK_TREE=$WEBROOT git checkout -f
    #git --work-tree=/srv/www/apps.legendboats.com --git-dir=/srv/repo/apps.legendboats.git checkout -f

    cd $WEBROOT

    # Check if a composer.json file is present
    if [ -f composer.json ]; then
    # Install or update packages specified in the lock file
    composer install
    fi

    # bring the application down for maintenance. avoid the artisan command
    touch storage/meta/down
    echo "Application is now down."

    # remove compiled/cache files if they exist
    rm -f bootstrap/compiled.php
    rm -f app/storage/meta/services.json

    # install packages, this also regenerates the autoloader
    if [[ $dev ]]; then
    composer install --no-scripts
    else
    composer install --no-scripts --no-dev --no-interaction --prefer-dist
    fi

    # display the environment
    php artisan env

    # run any outstanding migrations
    php artisan migrate --force

    if [[ ! $dev ]]; then
    # optimize autoloader and compile common classes
    php artisan optimize --force
    fi