Deploy to EC2 #8
This file contains hidden or 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: Deploy to EC2 | |
| on: | |
| workflow_run: | |
| workflows: ["CI/CD Pipeline"] | |
| types: | |
| - completed | |
| branches: [main] | |
| jobs: | |
| deploy: | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to EC2 | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| cd /home/ubuntu/KBILabs | |
| git pull origin main | |
| pip install -r requirements.txt | |
| sudo systemctl restart kbi-api | |
| sleep 5 | |
| sudo systemctl status kbi-api | |
| echo "✅ Deployment complete!" |