name: Image push for master
on: 
  push:
    branches:
      - master
env:
  image-push-owner: 'k8snetworkplumbingwg'
jobs:
  push-thick-amd64:
    name: Image push thick image/amd64
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v4

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

      - name: Login to GitHub Container Registry
        if: ${{ github.repository_owner == env.image-push-owner }}
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Push container image for thick plugin
        if: ${{ github.repository_owner == env.image-push-owner }}
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: |
            ghcr.io/${{ github.repository }}:latest-thick
            ghcr.io/${{ github.repository }}:snapshot-thick
          file: images/Dockerfile.thick
          platforms: linux/amd64

  push-thin:
    name: Image push thin image
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v4

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

      - name: Login to GitHub Container Registry
        if: ${{ github.repository_owner == env.image-push-owner }}
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Push thin container image
        if: ${{ github.repository_owner == env.image-push-owner }}
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: |
            ghcr.io/${{ github.repository }}:latest
            ghcr.io/${{ github.repository }}:snapshot
          file: images/Dockerfile
          platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x
          sbom: false
          provenance: false

      - name: Push thin container debug image
        if: ${{ github.repository_owner == env.image-push-owner }}
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: |
            ghcr.io/${{ github.repository }}:latest-debug
            ghcr.io/${{ github.repository }}:snapshot-debug
          file: images/Dockerfile.debug
          platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x
          sbom: false
          provenance: false

# TODO: need to fix this action
#  push-origin:
#    name: Image push/origin
#    runs-on: ubuntu-latest
#    steps:
#      - name: Check out code into the Go module directory
#        uses: actions/checkout@v4
#
#      - name: Set up Docker Buildx
#        uses: docker/setup-buildx-action@v3
#
#      - name: Login to GitHub Container Registry
#        if: github.repository_owner == 'k8snetworkplumbingwg'
#        uses: docker/login-action@v3
#        with:
#          registry: ghcr.io
#          username: ${{ github.repository_owner }}
#          password: ${{ secrets.GITHUB_TOKEN }}
#
#      - name: Push container image
#        if: github.repository_owner == 'k8snetworkplumbingwg'
#        uses: docker/build-push-action@v5
#        with:
#          context: .
#          push: true
#          tags: |
#            ghcr.io/${{ github.repository }}:latest-origin
#            ghcr.io/${{ github.repository }}:snapshot-origin
#          file: images/Dockerfile.openshift

