Maestro is compatible with all CI systems and provides native integrations with a number of common providers including GitHub Actions. You can start running your Flows in CI with just a few lines of configuration using the [Maestro Cloud GitHub Action](http://github.com/mobile-dev-inc/action-maestro-cloud).

## Create a Maestro Cloud account

This doesn’t cost anything up front and you’ll have $10 of free credit each month to play around with the platform. If you haven’t already, start by creating a Maestro Cloud account: [Create a Maestro Cloud Account](https://signin.maestro.dev/sign-up)

## Add your API key secret

The GitHub Action will need to authenticate with Maestro Cloud. So the first step is to expose your API key as a GitHub “Repository Secret”.

**Grab your API key**

1. Log in to [Maestro Cloud Console](https://signin.maestro.dev/sign-up), click on your username in bottom left corner and click on View API Key
2. Copy your API Key and save it somewhere. You will need it in next steps!

**Add your API key as a “Repository Secret”**

1. Navigate to your GitHub repo and click on Settings in top nav bar.
2. In repository settings page click on `Secrets -> Actions`. It will open Action Secrets page.
3. On Action Secrets page, click on `New Repository Secret` button. Use `MAESTRO_CLOUD_API_KEY` as the secret name and paste your API key from the previous step into the “Secret” value text box. Click “Add Secret” to add the secret.

## Commit your Maestro Flows to your repository

Create a `.maestro/` directory at the root of your repository and commit your Flows there:

```
<root>
├── .maestro/
│   ├── Login.yaml
│   ├── Add to Cart.yaml
│   └── Search.yaml
```

It’s common to have some Flow files that are only meant to be executed as part of another Flow via the `runFlow` command. These “subflows” can be nested under a subdirectory to prevent them from running as a top-level Flow.

```
<root>
├── .maestro/
│   ├── subflows/
│   │   └── MySubflow.yaml
│   ├── Login.yaml
│   ├── Add to Cart.yaml
│   └── Search.yaml
```

## Update your GitHub Actions workflow

Next, you’ll need to update your GitHub Actions workflow to add in the Maestro Cloud step. Here are a couple examples of working workflow files for Android and iOS:

**Android Workflow**

```
# .github/workflows/android.yaml

name: Build and upload to Maestro Cloud

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  maestro-cloud:
    runs-on: ubuntu-latest
    outputs:
      app: app/build/outputs/apk/debug
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          java-version: 11
          distribution: 'temurin'
      - run: ./gradlew assembleDebug
      - uses: mobile-dev-inc/action-maestro-cloud@v1.1.1
        with:
          api-key: ${{ secrets.MAESTRO_CLOUD_API_KEY }}
          app-file: app/build/outputs/apk/debug/app-debug.apk
```

**iOS Workflow**

```
name:  Mobile Dev Action iOS

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: macOS-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-xcode@v2
        with:
          xcode-version: 12
      - run: xcodebuild -project MyApp.xcodeproj -scheme MyApp -destination 'platform=iOS Simulator,name=iPhone 11'
      - uses: mobile-dev-inc/action-maestro-cloud@v1.1.1
        with:
          api-key: ${{ secrets.MAESTRO_CLOUD_API_KEY }}
          app-file: <app_name>.app
```

The workflows above execute generally the same steps for each platform:

- For every `push or pull_request` to `main` branch trigger this job
- Build the application
- Upload the built application and Flow files to Maestro Cloud
- Note the `MAESTRO_CLOUD_API_KEY` is the same secret you added to your Github repository earlier

## That’s it!

Check out the Maestro Cloud Action [README](https://github.com/mobile-dev-inc/action-maestro-cloud) for more information on how to configure the step.
