Merge pull request #3654 from ColoredCow/master #192
This file contains 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
name: Production Deployment | |
on: | |
push: | |
branches: [release] | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
# uses GitHub environment | |
environment: | |
name: Production | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Deploy to production | |
uses: appleboy/ssh-action@master | |
env: | |
SSH_BUILD_DIRECTORY: ${{ secrets.SSH_BUILD_DIRECTORY }} | |
SSH_POST_BUILD_SCRIPT: post_build_script.sh | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
envs: SSH_BUILD_DIRECTORY,SSH_POST_BUILD_SCRIPT | |
script: | | |
cd $SSH_BUILD_DIRECTORY | |
echo "Enabling maintenance mode" | |
php artisan down | |
echo "Pulling latest code" | |
git checkout -f | |
git pull origin release | |
php artisan migrate --force | |
echo "Running composer" | |
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --optimize-autoloader --no-dev | |
composer dump-autoload | |
echo "Running npm" | |
npm install | |
npm run production | |
echo "Optimizing Laravel app" | |
php artisan config:cache | |
php artisan route:cache | |
php artisan view:cache | |
echo "Disabling maintenance mode" | |
php artisan up | |
if test -f "$SSH_POST_BUILD_SCRIPT"; then | |
echo "Running post build script" | |
sh ./$SSH_POST_BUILD_SCRIPT | |
fi |