name: Docker Build And Push To Docker Hub

on:
  push:
    branches: [ main ]
    paths: 
      - 'appmanage/Dockerfile'
      - 'appmanage/main.py'
      - 'appmanage/config/*'

jobs:
  build:
    name: Build Docker image
    runs-on: ubuntu-latest
    env:
      TAGS: latest
    steps:
      - uses: actions/checkout@v2
        name: Check out code
        
      - uses: mr-smithers-excellent/docker-build-push@v5
        name: Build & push Docker image
        with:
          image: websoft9dev/appmanage
          tags: dev
          registry: docker.io
          dockerfile: appmanage/Dockerfile
          directory: appmanage
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
          
      - name: add readme file
        run: | 
          cd appmanage
          touch myread.md
          echo "This repository is the easiest appmanage deployment on GitHub and DockerHub  "' 
          ```  
             git clone https://github.com/Websoft9/Stackhub.git  
             sudo docker network create websoft9 && cd Stackhub/appmanage &&  sudo docker compose up -d  
          ```' > myread.md
          
      - name: Docker Hub Description
        uses: peter-evans/dockerhub-description@v3
        with:
         username: ${{ secrets.DOCKER_USERNAME }}
         password: ${{ secrets.DOCKER_PASSWORD }}
         repository: websoft9dev/appmanage
         readme-filepath: appmanage/myread.md
