name: "time-to-k8s benchmark"
on:
  workflow_dispatch:
  release:
    types: [released]
env:
  GOPROXY: https://proxy.golang.org
  GO_VERSION: '1.19.1'
permissions:
  contents: read

jobs:
  benchmark:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
    - name: Checkout submodules
      run: git submodule update --init
    - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f
      with:
          go-version: ${{env.GO_VERSION}}
    - name: time-to-k8s Benchmark
      id: timeToK8sBenchmark
      run: |
          ./hack/benchmark/time-to-k8s/time-to-k8s.sh
          echo "::set-output name=version::$(minikube version --short)"
    - name: Create PR
      uses: peter-evans/create-pull-request@18f90432bedd2afd6a825469ffd38aa24712a91d
      with:
        token: ${{ secrets.MINIKUBE_BOT_PAT }}
        commit-message: add time-to-k8s benchmark for ${{ steps.timeToK8sBenchmark.outputs.version }}
        committer: minikube-bot <minikube-bot@google.com>
        author: minikube-bot <minikube-bot@google.com>
        branch: addTimeToK8s${{ steps.timeToK8sBenchmark.outputs.version }}
        push-to-fork: minikube-bot/minikube
        base: master
        delete-branch: true
        title: Add time-to-k8s benchmark for ${{ steps.timeToK8sBenchmark.outputs.version }}
        body: Updating time-to-k8s benchmark as part of the release process
