apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: update-gesisbinder
spec:
  schedule: "*/5 * * * *"
  # Setting a limit to 0 corresponds to keeping none of the corresponding kind of jobs after they finish.
  successfulJobsHistoryLimit: 5
  failedJobsHistoryLimit: 70
  jobTemplate:
    spec:
      template:
        metadata:
          name: update-gesisbinder
        spec:
          restartPolicy: OnFailure
          containers:
          - name: update-gesisbinder
            image: python:3.7.4-stretch
            command: ["/bin/sh"]
            args: ["-c", "cd ~ && git clone https://github.com/gesiscss/orc.git orc_repo && pip install -r orc_repo/gesisbinder/bot/requirements.txt --quiet && python orc_repo/gesisbinder/bot/bot.py"]
            env:
              - name: GL_BOT_TOKEN
                valueFrom:
                  secretKeyRef:
                    name: bot-data
                    key: token
              - name: GL_BOT_NAME
                valueFrom:
                  secretKeyRef:
                    name: bot-data
                    key: name
              - name: GL_BOT_EMAIL
                valueFrom:
                  secretKeyRef:
                    name: bot-data
                    key: email
