name: NginxProxyManage  Build And Push To DockerHub

on:
  push:
    branches: [main]
    paths:
      - "docker/proxy/Dockerfile"

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=").*?(?=")' docker/proxy/Dockerfile)
          echo $version
          echo "::set-output name=version::$version"
          new_version=${version},latest
          echo "VERSION=$new_version" >> $GITHUB_ENV

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