variables:
  - &golang_image 'docker.io/golang:1.24'
  - &qa_repo 'https://github.com/opencloud-eu/qa.git'
  - &qa_repo_branch 'main'
  - &current_repo_id '11'
  - &ci_woodpecker_url
    from_secret: oc_ci_url

when:
  - event:
      - push
      - manual
    branch: ${CI_REPO_DEFAULT_BRANCH}
    status:
      - success
      - failure
  - event: pull_request
    status:
      - failure
  - event: cron
    cron: nightly*
    status:
      - success
      - failure

depends_on:
  - build
  - ui-tests

skip_clone: true

steps:
  - name: notify
    image: *golang_image
    environment:
      HTTP_PROXY:
        from_secret: ci_http_proxy
      HTTPS_PROXY:
        from_secret: ci_http_proxy
      MATRIX_HOME_SERVER: matrix.org
      MATRIX_ROOM_ALIAS:
        from_secret: opencloud-notifications-channel
      MATRIX_USER:
        from_secret: opencloud-notifications-user
      MATRIX_PASSWORD:
        from_secret: opencloud-notifications-user-password
      QA_REPO: *qa_repo
      QA_REPO_BRANCH: *qa_repo_branch
      CI_WOODPECKER_URL: *ci_woodpecker_url
      CI_REPO_ID: *current_repo_id
      CI_WOODPECKER_TOKEN: no-auth-needed-on-this-repo
    commands:
      - git clone --single-branch --branch $QA_REPO_BRANCH $QA_REPO /tmp/qa
      - cd /tmp/qa/scripts/matrix-notification/
      - if [ "$CI_PIPELINE_EVENT" = "cron" ]; then MESSAGE_SUFFIX_WHEN_FAILED="CC @artur @pradip.subedi @prashantgrg"; fi
      - go run matrix-notification.go
