Skip to content

Instantly share code, notes, and snippets.

@JunaidQadirB
Created January 4, 2021 18:23
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JunaidQadirB/f956c0d05973d62f9c144fa8f9eca50d to your computer and use it in GitHub Desktop.
Save JunaidQadirB/f956c0d05973d62f9c144fa8f9eca50d to your computer and use it in GitHub Desktop.
Github Action to deploy a Laravel App from release tag
name: CD
on:
release:
types:
- released
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GH_TOKEN }}
- run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Deploy App
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
username: ${{ secrets.SSH_USERNAME }}
source: "./"
target: "/var/www/html"
- name: Configure and make the app live
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
username: ${{ secrets.SSH_USERNAME }}
script: |
set -e
echo "Deploying application ..."
cd /var/www/html
(php artisan down) || true
composer install --no-interaction --prefer-dist --optimize-autoloader
php artisan migrate --force
sudo chmod 777 -R /var/www/html/bootstrap/cache/
sudo chmod 777 -R /var/www/html/storage/
php artisan optimize
echo "" | sudo service php7.4-fpm reload
php artisan up
echo "Application deployed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment