apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: updating-mindspore-hub
  namespace: mindspore-website
spec:
  schedule: "0 */12 * * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          imagePullSecrets:
            - name: huawei-swr-image-pull-secret
          containers:
            - name: mindspore-hub-update
              image: swr.cn-north-4.myhuaweicloud.com/opensourceway/common/alpine_with_curl:0.0.1
              command:
                - /bin/sh
                - -c
                - |
                  [ ! -d "./hub" ] &&  git clone https://gitee.com/mindspore/hub.git;
                  cd hub && git pull origin master
                  curl  --user ${API_USER}:${API_PASS} http://mindspore-website-service.mindspore-website.svc.cluster.local/hubInfo/initHubInfo
              volumeMounts:
                - mountPath: /mnt/share/mindspore_repository
                  name: website-hub-data-volume
              env:
                - name: API_USER
                  valueFrom:
                    secretKeyRef:
                      key: api_user
                      name: mindspore-website-secrets
                - name: API_PASS
                  valueFrom:
                    secretKeyRef:
                      key: api_pass
                      name: mindspore-website-secrets
          volumes:
            - name: website-hub-data-volume
              persistentVolumeClaim:
                claimName: website-hub-data
