tidy:
  script:
    - node lib/cli tidy
  stage: maintenance
  only:
    variables:
      - $MAINTENANCE_MODE == "tidy"
  tags:
    - secrecy

remind:
  script:
    - node lib/cli remind
  stage: maintenance
  only:
    variables:
      - $MAINTENANCE_MODE == "remind"
  tags:
    - secrecy

unlabel:
  script:
    - node lib/cli tidy
    - node lib/cli unlabel
  stage: maintenance
  only:
    variables:
      - $MAINTENANCE_MODE == "unlabel"
  tags:
    - secrecy

renovate:
  image: renovate/renovate:slim
  services:
    - docker:dind
  cache:
    key: ${CI_COMMIT_REF_SLUG}-renovate
    paths:
      - $CI_PROJECT_DIR/renovate
  resource_group: production
  stage: maintenance
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker:2376
    DOCKER_TLS_VERIFY: 1
    DOCKER_TLS_CERTDIR: /certs
    DOCKER_CERT_PATH: /certs/client
    RENOVATE_EXTENDS: 'gitlab>openstapps/projectmanagement'
    RENOVATE_BASE_DIR: $CI_PROJECT_DIR/renovate
    RENOVATE_ENDPOINT: $CI_API_V4_URL
    RENOVATE_PLATFORM: gitlab
    RENOVATE_OPTIMIZE_FOR_DISABLED: 'true'
    RENOVATE_REPOSITORY_CACHE: 'true'
    RENOVATE_REQUIRE_CONFIG: 'ignored'
    RENOVATE_ONBOARDING: 'false'
    RENOVATE_IGNORE_PR_AUTHOR: 'true'
    RENOVATE_LOG_FILE: renovate-log.ndjson
    RENOVATE_LOG_FILE_LEVEL: info
    LOG_LEVEL: warn
  only:
    variables:
      - $RENOVATE == "true"
  tags:
    - secrecy
  timeout: 2h
  artifacts:
    when: always
    expire_in: 1d
    paths:
      - '$RENOVATE_LOG_FILE'
  before_script: []
  script:
    - renovate $RENOVATE_EXTRA_FLAGS
