changes #10
This file contains 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 Node Application | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v4 | |
- name: Login to docker hub | |
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build Docker Image | |
run: docker build -t rajpatelbot/noteapp-backend . | |
- name: Publish Image to docker hub | |
run: docker push rajpatelbot/noteapp-backend:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Pull image from docker hub | |
run: docker pull rajpatelbot/noteapp-backend:latest | |
- name: Delete old container | |
run: docker rm -f nodejs-app-container | |
- name: Run Docker Container | |
run: docker run -d -p 4000:4000 --name nodejs-app-container -e MONGO_PASSWORD='${{ secrets.MONGO_PASSWORD }}' rajpatelbot/noteapp-backend |