# Fan-out fan-in with build-router-start

**URL:** <https://discuss.bitrise.io/t/fan-out-fan-in-with-build-router-start/8815>\
**Category:** Question & Answer\
**Created:** [April 19, 2019, 3:39pm UTC](https://discuss.bitrise.io/t/fan-out-fan-in-with-build-router-start/8815 "2019-04-19T15:39:40Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![max](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@max](https://discuss.bitrise.io/u/max)\
**Post date:** [April 25, 2019, 6:14am UTC](https://discuss.bitrise.io/t/fan-out-fan-in-with-build-router-start/8815/5 "2019-04-25T06:14:36Z")

</div>

So far I ended up with the following:

- bitrise.yml in web - accepts call and dispatches to actual workflow in repo:

```auto
---
format_version: '7'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
workflows:
  ci:
    after_run:
    - run_from_repo
  run_from_repo:
    steps:
    - activate-ssh-key:
        run_if: ''
    - git-clone: {}
    - script:
        title: continue from repo
        inputs:
        - content: |-
            #!/bin/bash
            set -ex
            echo "workflow to run from trigger: ${WORKFLOW_TO_RUN:-primary}"
            bitrise run "${WORKFLOW_TO_RUN:-primary}"
  ios:
    after_run:
    - run_from_repo
    steps:
    - script@1.1.5:
        inputs:
        - content: |
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            envman add --key WORKFLOW_TO_RUN --value ios
  android:
    after_run:
    - run_from_repo
    steps:
    - script@1.1.5:
        inputs:
        - content: |
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            envman add --key WORKFLOW_TO_RUN --value android
trigger_map:
- push_branch: task/ci-2.0
  workflow: ci

```

- bitrise.yml in repo - does actual job of building an app:

```auto
format_version: "7"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
trigger_map:
- push_branch: '*'
  workflow: primary
- pull_request_source_branch: '*'
  workflow: primary
workflows:
  primary:
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.14: {}
    - script@1.1.5:
        title: Do anything with Script step
        inputs:
        - content: |-
            #!/bin/bash
            echo "Trigger $SOURCE_BITRISE_BUILD_NUMBER"
    - build-router-start@0.11.2:
        inputs:
        - access_token: $BITRISE_ACCESS_TOKEN
        - workflows: |-
            ios
            android
    - script@1.1.5:
        title: Do anything with Script step
        inputs:
        - content: |-
            #!/bin/bash
            echo "slugs? $ROUTER_STARTED_BUILD_SLUGS"
    - build-router-wait@0.9.1:
        inputs:
        - access_token: $BITRISE_ACCESS_TOKEN
        - buildslugs: $ROUTER_STARTED_BUILD_SLUGS

  ios:
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.14: {}
    - script@1.1.5:
        title: Do anything with Script step
        inputs:
        - content: |-
            #!/bin/bash
            # build ios

  android:
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.14: {}
    - script@1.1.5:
        title: Do anything with Script step
        inputs:
        - content: |-
            #!/bin/bash
            # build android

```

I wish this kind of a set up was a bit more straightforward…

---

_[View the full topic](https://discuss.bitrise.io/t/fan-out-fan-in-with-build-router-start/8815)._
