Advertisement
elliottchong

.github/workflows/deploy.yml

Aug 20th, 2023
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. name: Deploy
  2.  
  3. on:
  4. push:
  5. branches:
  6. - main
  7.  
  8. jobs:
  9. Production:
  10. name: Deploy to DigitalOcean
  11. runs-on: ubuntu-latest
  12. environment: Production
  13. steps:
  14. - uses: actions/checkout@v3
  15. - name: Build & Deploy
  16. env:
  17. SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
  18. SSH_HOST: ${{secrets.SSH_HOST}}
  19. USER_NAME: ${{secrets.USER_NAME}}
  20.  
  21. run: |
  22. echo "Deploying to EC2"
  23. echo "${{ secrets.SSH_PRIVATE_KEY }}" > private_key && chmod 600 private_key
  24. ssh -o StrictHostKeyChecking=no -i private_key ${{ secrets.USER_NAME }}@${{ secrets.SSH_HOST }} '
  25. cd /root/learning-journey &&
  26. git reset --hard &&
  27. git checkout main &&
  28. git pull origin main &&
  29. docker-compose down &&
  30. docker-compose rm -fsv &&
  31. docker-compose up --build -d
  32. '
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement