From 8e26d9559ce2340639ac4f8c0340d9924ae46568 Mon Sep 17 00:00:00 2001 From: Somnath Chataraj Date: Tue, 30 Jul 2024 19:01:51 +0530 Subject: [PATCH] Add deploy to EC2 pipeline --- .github/workflows/deploy.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index fccaa02..7c4040c 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -29,3 +29,18 @@ jobs: - name: Verify Pushed Image run: docker pull somnath910/statuscode1:latest # Replace with your Docker Hub username and repository + + - name: Deploy to EC2 + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + key: ${{ secrets.SSH_KEY }} + script: | + sudo docker pull somnath910/statuscode1:latest + sudo docker stop web-app || true + sudo docker rm web-app || true + sudo docker run -d --name web-app -e DATABASE_URL ${{ secrets.DATABASE_URL }} PORT ${{secrets.PORT}} SECRET ${{ secrets.SECRET }} BREVO_USER ${{ secrets.BREVO_USER }} BREVO_PASSWORD ${{ secrets.BREVO_PASSWORD }} BREVO_HOST ${{ secrets.BREVO_HOST }} BREVO_PORT ${{ secrets.BREVO_PORT }} -p 3005:3000 somnath910/statuscode1:latest + + +