---
name: Docker

on:
  push:
    branches:
      - eodatasets3
    paths:
      - "**"

  pull_request:
    branches:
      - eodatasets3

  release:
    types: [created, edited, published]

env:
  IMAGE_NAME: opendatacube/eo-datasets

jobs:
  docker:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout git
        uses: actions/checkout@v2

      - name: Deterimine docker tags from repo
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.IMAGE_NAME }}

      - name: Log the labels
        run: echo '${{ steps.meta.outputs.labels }}'

      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to DockerHub
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v1
        with:
          username: gadockersvc
          password: ${{ secrets.GADOCKERSVC_PASSWORD }}

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          builder: ${{ steps.buildx.outputs.name }}
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            ENVIRONMENT=deployment

---
name: Docker

on:
  push:
    branches:
      - develop
    paths:
      - "**"

  pull_request:
    branches:
      - develop

  release:
    types: [created, edited, published]

env:
  IMAGE_NAME: ${{ github.repository }}

jobs:
  build_n_push:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Git
        uses: actions/checkout@v2

      - name: Determine Docker info from repo
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.IMAGE_NAME }}

      - name: Log the image labels
        run: echo '${{ steps.meta.outputs.labels }}'

      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to DockerHub
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v1
        with:
          username: gadockersvc
          password: ${{ secrets.GADOCKERSVC_PASSWORD }}

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          builder: ${{ steps.buildx.outputs.name }}
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            ENVIRONMENT=deployment

Prepare for eodatasets3->develop branch rename
Prepare for eodatasets3->develop branch rename
