# This is the copy of the config used to trigger the bitrise.yml file configuration on this repo, from the Bitrise.io platform.
---
format_version: "5"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: react-native
meta:
  bitrise.io:
    stack: osx-xcode-15.0.x
    machine_type_id: g2-m1.4core

trigger_map:
  - push_branch: develop
    workflow: Internal-Testing-Build
  - push_branch: master
    workflow: Internal-Testing-Build
  - pull_request_source_branch: "*"
    workflow: Internal-Testing-Build

workflows:
  _setup:
    steps:
      - activate-ssh-key@4:
          run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
      - git::https://github.com/onfido/bitrise-step-open-vpn.git@0.0.5:
          inputs:
            - subnet1: 10.103.0.0
            - subnet2: 10.105.0.0
            - host: cvpn-endpoint-069dfbb854bc48233.prod.clientvpn.eu-west-1.amazonaws.com
      - script@1:
          title: Get GitLab IPs
          inputs:
            - content:
                "#!/usr/bin/env bash\n# fail if any commands fails\nset -e\n# debug
                log\nset -x\n\nGITLAB_IPS=$(host gitlab.eu-west-1.mgmt.onfido.xyz 10.103.20.5
                |  cut -d ' ' -f 4 | grep .)\n\nfor IP in $GITLAB_IPS; do\n  echo $IP
                gitlab.eu-west-1.mgmt.onfido.xyz | sudo tee -a /etc/hosts\ndone                "
      - gitlab-status@0.12:
          inputs:
            - private_token: "$GITLAB_ACCESS_TOKEN"
            - context: "$GITLAB_STATUS_CONTEXT"
            - description: "$GITLAB_STATUS_DESCRIPTION"
            - preset_status: running
            - api_base_url: https://gitlab.eu-west-1.mgmt.onfido.xyz/api/v4
      - git-clone: {}

  _teardown:
    steps:
      - gitlab-status@0.12:
          inputs:
            - context: "$GITLAB_STATUS_CONTEXT"
            - description: "$GITLAB_STATUS_DESCRIPTION"
            - private_token: "$GITLAB_ACCESS_TOKEN"
            - api_base_url: https://gitlab.eu-west-1.mgmt.onfido.xyz/api/v4

  Wrapper-Android:
    envs:
      - GITLAB_STATUS_CONTEXT: Wrapper android
      - GITLAB_STATUS_DESCRIPTION: Build and test android
    before_run:
      - _setup
    after_run:
      - _teardown
    steps:
      - bitrise-run@0.9:
          inputs:
            - bitrise_config_path: "./bitrise.yml"

  Wrapper-iOS:
    envs:
      - GITLAB_STATUS_CONTEXT: Wrapper iOS
      - GITLAB_STATUS_DESCRIPTION: Build and test iOS
    before_run:
      - _setup
    after_run:
      - _teardown
    steps:
      - bitrise-run@0.9:
          inputs:
            - bitrise_config_path: "./bitrise.yml"

  Applause-Build:
    before_run:
      - _setup
    after_run:
      - _teardown
    steps:
      - bitrise-run@0.9:
          inputs:
            - bitrise_config_path: "./bitrise.yml"

  Dogfooding-Build:
    before_run:
      - _setup
    after_run:
      - _teardown
    steps:
      - bitrise-run@0.9:
          inputs:
            - bitrise_config_path: "./bitrise.yml"

  Internal-Testing-Build:
    before_run:
      - _setup
    after_run:
      - _teardown
    steps:
      - bitrise-run@0.9:
          inputs:
            - bitrise_config_path: "./bitrise.yml"

  NPM-Production-Validation:
    envs:
      - GITLAB_STATUS_CONTEXT: Testing npm integration
      - GITLAB_STATUS_DESCRIPTION: Testing npm integration
    before_run:
      - _setup
    after_run:
      - _teardown
    steps:
      - bitrise-run@0.9:
          inputs:
            - bitrise_config_path: "./bitrise.yml"
