apiVersion: batch/v1
kind: CronJob
metadata:
  name: release-schedules-update
  namespace: ocp-test-platform
spec:
  schedule: "0 1 * * *" # 1 AM every day
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: release-schedules-update
            image: registry.ci.openshift.org/ci/schedule-generator:latest
            env:
            - name: GITLAB_CLONER_SECRET
              valueFrom:
                secretKeyRef:
                  name: gitlab-cloner
                  key: token
            imagePullPolicy: IfNotPresent
            args:
            - -c
            - |
              set -euo pipefail
              TOKEN=$(echo ${GITLAB_CLONER_SECRET} | xargs)
              mkdir -p /tmp/schedule
              cd /tmp/schedule
              git init
              git config --local http.sslVerify false
              git fetch https://oauth2:${TOKEN}@gitlab.cee.redhat.com/ocp-release-schedule/schedule.git
              git checkout FETCH_HEAD
              schedule-generator --kubeconfig /etc/kube/sa.release-schedules-cm-updater.app.ci.config --schedule-dir . --dry-run=false
            command:
            - /bin/bash
            volumeMounts:
            - name: kube
              mountPath: "/etc/kube"
              readOnly: true
          restartPolicy: OnFailure
          volumes:
          - name: kube
            secret:
              secretName: release-schedules-cm-updater-credentials
