Created
April 11, 2023 23:46
-
-
Save muath-ye/d4cf6d1bf3090b3e3b6d8c2c64b91c25 to your computer and use it in GitHub Desktop.
Laravel auto deployment
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: Auto Deployment | |
on: | |
push: | |
branches: | |
- production | |
# on: [workflow_dispatch] | |
jobs: | |
prepare-servers-connection: | |
name: "Connecting to: ${{ vars.SERVER_NAME }}" | |
runs-on: ubuntu-latest | |
steps: | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@v0.1.9 | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
password: ${{ secrets.SSH_PASS }} | |
port: ${{ secrets.SSH_PORT }} | |
script: whoami | |
artisan-down: | |
name: "${{ vars.SERVER_NAME }}: Switch on maintenance mode" | |
runs-on: ubuntu-latest | |
needs: prepare-servers-connection | |
steps: | |
- name: Artisan down | |
run: sudo sshpass -p ${{ secrets.SSH_PASS }} -v ssh -o "HostkeyAlgorithms=ssh-dss" -o "StrictHostKeyChecking no" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd ${{ vars.PATH }} && php artisan down' | |
pull-updates: | |
name: "Pull chanages from production branch" | |
runs-on: ubuntu-latest | |
needs: [prepare-servers-connection, artisan-down] | |
steps: | |
- name: Pull origin production | |
run: sudo sshpass -p ${{ secrets.SSH_PASS }} -v ssh -o "HostkeyAlgorithms=ssh-dss" -o "StrictHostKeyChecking no" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'eval `ssh-agent -s` && ssh-add ~/.ssh/${{ vars.SSH_KEY_NAME }} && cd ${{ vars.PATH }} && git pull origin production' | |
composer-install: | |
name: "Install composer dependences" | |
runs-on: ubuntu-latest | |
needs: pull-updates | |
steps: | |
- name: Composer install | |
run: sudo sshpass -p ${{ secrets.SSH_PASS }} -v ssh -o "HostkeyAlgorithms=ssh-dss" -o "StrictHostKeyChecking no" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd ${{ vars.PATH }} && php composer.phar install --ignore-platform-req=ext-sodium --optimize-autoloader --no-dev' | |
artisan-commands: | |
name: "Artisan commands" | |
runs-on: ubuntu-latest | |
needs: [prepare-servers-connection, composer-install] | |
steps: | |
- name: Artisan cache:clear | |
run: sudo sshpass -p ${{ secrets.SSH_PASS }} -v ssh -o "HostkeyAlgorithms=ssh-dss" -o "StrictHostKeyChecking no" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd ${{ vars.PATH }} && php artisan cache:clear' | |
artisan-config-clear: | |
name: "Artisan config clear" | |
runs-on: ubuntu-latest | |
needs: [prepare-servers-connection, composer-install] | |
steps: | |
- name: Artisan config:clear | |
run: sudo sshpass -p ${{ secrets.SSH_PASS }} -v ssh -o "HostkeyAlgorithms=ssh-dss" -o "StrictHostKeyChecking no" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd ${{ vars.PATH }} && php artisan config:clear' | |
artisan-route-clear: | |
name: "Artisan route clear" | |
runs-on: ubuntu-latest | |
needs: [prepare-servers-connection, composer-install] | |
steps: | |
- name: Artisan route:clear | |
run: sudo sshpass -p ${{ secrets.SSH_PASS }} -v ssh -o "HostkeyAlgorithms=ssh-dss" -o "StrictHostKeyChecking no" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd ${{ vars.PATH }} && php artisan route:clear' | |
artisan-view-clear: | |
name: "Artisan view clear" | |
runs-on: ubuntu-latest | |
needs: [prepare-servers-connection, composer-install] | |
steps: | |
- name: Artisan view:clear | |
run: sudo sshpass -p ${{ secrets.SSH_PASS }} -v ssh -o "HostkeyAlgorithms=ssh-dss" -o "StrictHostKeyChecking no" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd ${{ vars.PATH }} && php artisan view:clear' | |
artisan-queue-restart: | |
name: "Artisan queue restart" | |
runs-on: ubuntu-latest | |
needs: [prepare-servers-connection, composer-install] | |
steps: | |
- name: Artisan queue:restart | |
run: sudo sshpass -p ${{ secrets.SSH_PASS }} -v ssh -o "HostkeyAlgorithms=ssh-dss" -o "StrictHostKeyChecking no" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd ${{ vars.PATH }} && php artisan queue:restart' | |
artisan-up: | |
name: "${{ vars.SERVER_NAME }} : Switch off maintenance mode" | |
runs-on: ubuntu-latest | |
needs: [prepare-servers-connection, artisan-commands, artisan-config-clear, artisan-route-clear, artisan-view-clear, artisan-queue-restart] | |
steps: | |
- name: Artisan up | |
run: sudo sshpass -p ${{ secrets.SSH_PASS }} -v ssh -o "HostkeyAlgorithms=ssh-dss" -o "StrictHostKeyChecking no" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd ${{ vars.PATH }} && php artisan up' |
Author
muath-ye
commented
Apr 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment