name: Upload docker containers modified for release branches

on:
  workflow_dispatch:
  push:
    paths:
      - '.github/workflows/docker.yml'
      - 'tf_sig_build_dockerfiles/**'
      - '!tf_sig_build_dockerfiles/README.md'
    branches:
      # Branch should match the TF branch name
      - "r[1-9].[0-9]+"

jobs:
  docker:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [python3.7, python3.8, python3.9, python3.10]
    steps:
      -
        name: Checkout
        uses: actions/checkout@v2
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      -
        name: Login to DockerHub
        uses: docker/login-action@v1 
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      -
        name: Login to GCR
        uses: docker/login-action@v1
        with:
          registry: gcr.io
          username: _json_key
          password: ${{ secrets.GCP_CREDS }}
      -
        name: Generate variables for cache busting and tag naming
        run: |
          echo "::set-output name=DATE::$(date +'%Y-%m-%d')"
          # Converts r2.9 to just 2.9
          echo "::set-output name=REF::$(echo $GITHUB_REF_NAME | sed 's/r//g')"
        id: vars
      -
        name: Build and push
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          push: true
          context: ./tf_sig_build_dockerfiles
          target: devel
          build-args: |
            PYTHON_VERSION=${{ matrix.python-version }}
            CACHEBUSTER=${{ steps.vars.outputs.DATE }}
          tags: |
            tensorflow/build:${{ steps.vars.outputs.REF }}-${{ matrix.python-version }}
            gcr.io/tensorflow-sigs/build:${{ steps.vars.outputs.REF }}-${{ matrix.python-version }}
          cache-from: type=registry,ref=tensorflow/build:${{ steps.vars.outputs.REF }}-${{ matrix.python-version }}
          cache-to: type=inline
      -
        name: Image digest
        run: echo ${{ steps.docker_build.outputs.digest }}


Add a workflow for handling branch-specific containers, if needed
Add a workflow for handling branch-specific containers, if needed
