{{ if .Values.actions_runner_controller.enabled }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: actions-runner-controller
  namespace: argocd #TODO move arc to isolated project
spec:
  destination:
    namespace: actions-runner-controller
    server: 'https://kubernetes.default.svc'
  sources:
  - repoURL: 'https://actions-runner-controller.github.io/actions-runner-controller'
    targetRevision: {{ .Values.actions_runner_controller.version }}
    chart: actions-runner-controller
    helm:
      values: |
        replicaCount: 1
        # Webhook
        webhookPort: 9443
        syncPeriod: 1m
        defaultScaleDownDelay: 10m
        # Authentication
        authSecret:
          enabled: true
          create: false
          name: arc-gh-token
          annotations: {}
  project: sys
  syncPolicy:
    managedNamespaceMetadata:
      labels:
        component: sys
    syncOptions:
      - CreateNamespace=true
      - ApplyOutOfSyncOnly=true
      - ServerSideApply=true
    {{- if .Values.actions_runner_controller.version }}
    automated:
      # selfHeal: false
      prune: true
    {{- end }}
{{ end }}
