File size: 1,517 Bytes
43dfddb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Deploy to EC2

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Install SSH Client
        run: sudo apt-get install -y openssh-client

      - name: Set up SSH
        uses: webfactory/ssh-agent@v0.5.3
        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

      - name: SSH Command
        run: |
          ssh -o StrictHostKeyChecking=no -i /tmp/deploy-key.pem ubuntu@3.6.59.40 'cd infinity_talks/ && git pull https://het-vaghasia:${{ secrets.GIT_TOKEN }}@github.com/hetvaghasia39/infinity_talks.git'
          ssh -i /tmp/deploy-key.pem ubuntu@3.6.59.40 'sudo systemctl stop daphne gunicorn; cd infinity_talks/; source .venv/bin/activate; pip install -r requirements.txt; ./manage.py migrate;'
          ssh -o StrictHostKeyChecking=no -i /tmp/deploy-key.pem ubuntu@3.6.59.40 'sudo systemctl restart gunicorn'
          ssh -i /tmp/deploy-key.pem ubuntu@3.6.59.40 'sudo systemctl daemon-reload'
          ssh -i /tmp/deploy-key.pem ubuntu@3.6.59.40 'sudo systemctl restart gunicorn.socket gunicorn.service'
          ssh -i /tmp/deploy-key.pem ubuntu@3.6.59.40 'sudo systemctl restart daphne'
          ssh -i /tmp/deploy-key.pem ubuntu@3.6.59.40 'sudo nginx -t && sudo systemctl restart nginx'
          ssh -i /tmp/deploy-key.pem ubuntu@3.6.59.40 'sudo systemctl status gunicorn'
          ssh -i /tmp/deploy-key.pem ubuntu@3.6.59.40 'sudo systemctl status daphne'