apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-ui-gh-runner-deployment
spec:
  selector:
    matchLabels:
      app: runner
  replicas: 1
  template:
    metadata:
      labels:
        app: runner
    spec:
      tolerations:
      - key: team
        operator: Equal
        value: ui
        effect: NoSchedule
      containers:
        - name: runner
          image: webui/runner:latest
          envFrom:
            - secretRef:
                name: web-ui-gh-runner-secret
          env:
            - name: REPO_OWNER
              value: nuxeo
            - name: REPO_NAME
              value: nuxeo-web-ui
          lifecycle:
            preStop:
              exec:
                command:
                  [
                    "/bin/bash",
                    "-c",
                    'RUNNER_ALLOW_RUNASROOT=1 ./config.sh remove --token $(curl -sS --request POST --url "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/runners/remove-token" --header "authorization: Bearer ${GITHUB_TOKEN}"  --header "content-type: application/json" | jq -r .token)',
                  ]
          resources:
            requests:
              memory: "3Gi"
              cpu: "3"
            limits:
              memory: "4Gi"
              cpu: "4"