Skip to content

Workflow file for this run

name: Deploy Node Application
on:
push:
branches:
- erp-dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Build Docker Image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/institute-management-backend .
- name: Publish Docker Image
run: docker push ${{ secrets.DOCKER_USERNAME }}/institute-management-backend:latest
publish:
needs: build
runs-on: self-hosted
steps:
- name: Clean up Docker
run: docker system prune -a --volumes -f
- name: Pull Docker Image
run: docker pull ${{ secrets.DOCKER_USERNAME }}/institute-management-backend:latest
- name: Delete old container if exists
run: |
if [ $(docker ps -a -q -f name=institute-management-backend) ]; then
docker rm -f institute-management-backend
fi
- name: Run Docker Container
run: docker run -d -p 5000:5000 --name institute-management-backend -e MONGO_URI='${{ secrets.MONGO_URI }}' institute-management-backend