Created
January 4, 2021 18:23
-
-
Save JunaidQadirB/f956c0d05973d62f9c144fa8f9eca50d to your computer and use it in GitHub Desktop.
Github Action to deploy a Laravel App from release tag
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: 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 [email protected] | |
- 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