Redeploy #19
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 the backend | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the code | |
| uses: actions/checkout@v2 | |
| - name: Docker login | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push to DockerHub | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile.backend | |
| push: true | |
| tags: harshitbreaksprod/meetdraw-be:${{ github.sha }} | |
| - name: Push to VM | |
| run: | | |
| echo "${{ secrets.SSH_PRIVATE_KEY_DIGITAL_OCEAN }}" &> ~/ssh_key | |
| mkdir ~/.ssh | |
| chmod 700 ~/ssh_key | |
| ssh -o StrictHostKeyChecking=no -i ~/ssh_key root@${{ secrets.DIGITAL_OCEAN_SSH_IP }} -t "docker pull harshitbreaksprod/meetdraw-be:${{ github.sha }} && docker stop meetdraw_be && docker rm meetdraw_be && docker run --name meetdraw_be -e SALTROUNDS=${{ secrets.SALTROUNDS }} -e JWT_SECRET=${{ secrets.JWT_SECRET }} -e PORT=${{ secrets.HTTP_PORT }} -e FRONTEND_ORIGINS=${{ secrets.FRONTEND_ORIGIN }} -d -p 3001:3001 harshitbreaksprod/meetdraw-be:${{ github.sha }}" |