diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3a0f346..4775ac8 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,34 +1,34 @@ -name: Docker Image CI +name: Docker Image CI/CD on: push: branches: [ "main" ] paths: - - 'Backend/**' # Update path to match your repo + - 'Backend/**' pull_request: branches: [ "main" ] - paths: - - 'Backend/**' jobs: - build: + build-push: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: ./Backend # Updated path - file: ./Backend/Dockerfile - push: true - tags: | - ${{ secrets.DOCKERHUB_USERNAME }}/sarthi-backend:latest - ${{ secrets.DOCKERHUB_USERNAME }}/sarthi-backend:${{ github.sha }} + - name: Checkout code + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: ./Backend + file: ./Backend/Dockerfile + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/sarthi-backend:latest + ${{ secrets.DOCKERHUB_USERNAME }}/sarthi-backend:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max