name: AppManage Build And Push To DockerHub

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

      - name: Get version
        run: |
          version=$(grep -Po '(?<=LABEL version=").*?(?=")' appmanage/Dockerfile)
          echo $version
          echo "::set-output name=version::$version"
          echo "VERSION=$version" >> $GITHUB_ENV

      - uses: mr-smithers-excellent/docker-build-push@v5
        name: Build & push Docker image
        with:
          image: websoft9dev/appmanage
          tags: ${{ env.VERSION }}
          addLatest: True
          registry: docker.io
          dockerfile: appmanage/Dockerfile
          directory: appmanage
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
