-
-
Save KABBOUCHI/ae737e6ccc1dc1b0b8ad7a87c5343492 to your computer and use it in GitHub Desktop.
Forge Deploy script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| APP_DIR=/home/forge/sub.domain.com | |
| RELEASE=$(date +%Y%m%d%H%M%S) | |
| RELEASE_DIR=$APP_DIR/releases/$RELEASE | |
| ARCHIVE=$RELEASE.tar.gz | |
| PHP=php7.1 | |
| [ -d $APP_DIR/releases ] || mkdir $APP_DIR/releases | |
| cd $APP_DIR/releases | |
| mkdir $RELEASE_DIR | |
| cd $RELEASE_DIR | |
| # Get the repo archive from a git ref (master in this case) | |
| # GitHub | |
| curl -L https://api.github.com/repos/username/repo/tarball/master?access_token=<TOKEN> > $ARCHIVE | |
| # wget https://api.github.com/repos/username/repo/tarball/master?access_token=<TOKEN> -O $ARCHIVE | |
| # GitLab | |
| # curl -H "PRIVATE-TOKEN: <TOKEN>" https://gitlab.com/username/repo/repository/archive.tar.gz?ref=master > $ARCHIVE | |
| # wget --header "PRIVATE-TOKEN: <TOKEN>" "https://gitlab.com/username/repo/repository/archive.tar.gz?ref=master" -O $ARCHIVE | |
| tar -zxvf $ARCHIVE --strip=1 > /dev/null | |
| rm -f $ARCHIVE | |
| # install php denendencies | |
| composer install --no-interaction --prefer-dist --no-dev --quiet --optimize-autoloader | |
| # Link storage | |
| rm -rf storage | |
| ln -nfs $APP_DIR/storage storage; | |
| # Link .env | |
| ln -nfs $APP_DIR/.env .env; | |
| # link the current dir | |
| cd $APP_DIR | |
| ln -nfs $RELEASE_DIR current | |
| cd $RELEASE_DIR | |
| php artisan config:clear | |
| php artisan cache:clear | |
| php artisan clear-compiled | |
| php artisan optimize | |
| #php artisan view:clear | |
| sudo service "$PHP-fpm" restart | |
| # sudo supervisorctl restart all | |
| # Remove old releases | |
| cd $APP_DIR/releases | |
| ls -dt ./* | tail -n +6 | xargs -d "\n" rm -rf; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment