From 4917bc3f96ac846111e9310bddd0b650aa23201d Mon Sep 17 00:00:00 2001 From: LuxShan Thavarasa <120371059+Luxshan2000@users.noreply.github.com> Date: Fri, 29 Sep 2023 02:02:16 +0530 Subject: [PATCH] Create backend.yml --- .github/workflows/backend.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/backend.yml diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 0000000..6af1903 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,32 @@ +name: CICD Backend + +on: + push: + branches: [main] + +jobs: + build: + runs-on: [ubuntu-latest] + steps: + - name: Checkout source + uses: actions/checkout@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build docker image + run: docker build -t luxshan/aws-pipeline . + - name: Publish image to docker hub + run: docker push luxshan/aws-pipeline:latest + + deploy: + needs: build + runs-on: [aws-ec2] + steps: + - name: Pull image from docker hub + run: docker pull luxshan/aws-pipeline + - name: Delete old container + run: docker rm -f aws-pipeline-container + - name: Run docker container + run: docker run -d -p 3000:3000 --name aws-pipeline-container luxshan/aws-pipeline