# This workflow triggers siegfried's automated benchmarks.
#
# Trigger it by creating a release (the main benchmark runs)
# or by a commit with a bench* tag. e.g. bench-2023-12-31
name: Benchmark
on: 
  push:
    tags:
      - bench*
  release:
    types: [released]
jobs:
  bench:
    runs-on: ubuntu-latest
    steps:
      - name: Install latest version of go
        uses: actions/setup-go@v5
        with:
          go-version: 1.x
      - name: Check out repository code
        uses: actions/checkout@v4
        with:
          repository: richardlehane/provisioner
      - name: Install provisioner  
        run: go install github.com/richardlehane/provisioner
      - name: Provision develop
        if: startsWith(github.ref_name, 'bench')
        run: provisioner -life=2h -max=0.2 -host=develop-RAND.itforarchivists.com -env=CHERRY_AUTH_TOKEN,PACKET_AUTH_TOKEN,RUNNER_AUTH,BB_ACCOUNT,BB_KEY scripts/develop.yaml 
        env:
          CHERRY_AUTH_TOKEN: ${{ secrets.CHERRY_AUTH_TOKEN }}
          PACKET_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }}
          RUNNER_AUTH: ${{ secrets.RUNNER_AUTH }}
          BB_ACCOUNT: ${{ secrets.BB_ACCOUNT }}
          BB_KEY: ${{ secrets.BB_KEY }}
      - name: Provision main
        if: startsWith(github.ref_name, 'v') # release
        run: provisioner -life=12h -max=-1 -host=bench-RAND.itforarchivists.com -env=CHERRY_AUTH_TOKEN,PACKET_AUTH_TOKEN,RUNNER_AUTH,BB_ACCOUNT,BB_KEY scripts/bench.yaml
        env:
          CHERRY_AUTH_TOKEN: ${{ secrets.CHERRY_AUTH_TOKEN }}
          PACKET_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }}
          RUNNER_AUTH: ${{ secrets.RUNNER_AUTH }}
          BB_ACCOUNT: ${{ secrets.BB_ACCOUNT }}
          BB_KEY: ${{ secrets.BB_KEY }}
