name: make docker-push

on:
  push:
    branches: [ main ]

jobs:
  push:
    name: Push Image
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        go: ["1.15"]
    steps:
    - uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go }}

    - uses: actions/checkout@v2
      with:
        fetch-depth: 0

    - name: Login to Quay
      uses: docker/login-action@v1
      with:
        registry: quay.io
        username: ${{ secrets.QUAY_USERNAME }}
        password: ${{ secrets.QUAY_PASSWORD }}

    - name: copy volume-replication-operator repo in go src
      run: |
        mkdir -p /home/runner/go/src/github.com/csi-addons
        cp -r /home/runner/work/volume-replication-operator/volume-replication-operator /home/runner/go/src/github.com/csi-addons

    - name: run docker-push
      working-directory: "/home/runner/go/src/github.com/csi-addons/volume-replication-operator"
      env:
        GOPATH: /home/runner/go
      run: |
        export PATH=$PATH:$GOPATH/bin
        export VERSION="2.3.2"
        wget https://github.com/kubernetes-sigs/kubebuilder/releases/download/v"$VERSION"/kubebuilder_"$VERSION"_linux_amd64.tar.gz
        tar -zxvf kubebuilder_"$VERSION"_linux_amd64.tar.gz
        export KUBEBUILDER_ASSETS="$(pwd)/kubebuilder_"$VERSION"_linux_amd64/bin"
        make docker-build
        make docker-push
