Middleman is distributed using the RubyGems package manager.
This means you will need both the Ruby language runtime installed and RubyGems to begin using Middleman.

MacOS comes prepackaged with Ruby, however, some of the Middleman's dependencies need to be compiled
during installation and on macOS that requires Xcode.
Xcode can be installed via the Mac App Store.
Alternately you can just install the Xcode Command Line Tools, that should be enough
if you don't want to install the full Xcode.app.

Once you have Ruby and Xcode (Command Line Tools), execute the following from the command line:

gem install middleman

This will install Middleman, its dependencies and the command-line tools for using Middleman.

To connect your repository with Bitrise, visit the Bitrise site.
You need to sign in with your Bitrise account, or sign up if you don't have one yet.
Once you're signed in, select Add new App in the top dropdown menu.

In the first step, you need to select the provider, where you store your code, in this case, GitHub.

In the second step, you will see a list of all your repositories on GitHub. Select the one you just created.

In the third step, you will get an alert, since the repository you are connecting is not an Xcode project.
Select "Configure Manually", then enter the branch name "master".

Once you created your project, select it in the Dashboard
and select the Workflow tab from the top menu.
We are going to add a bash script that will be executed on each build.
First, delete all the automatically created steps (if any).
Next, we need to add new steps.
You can add new steps by clicking on the + sign button between steps / in the step list and selecting the step
from the step list popup. Add the following steps to your Workflow, in this order:

Activate SSH key - unless you used the public, non SSH URL of the repository during the Add New App process

Once the configuration of your Workflow is complete,
you can run a build manually by clicking on the Start/Schedule a build button on the app's page (where you see the
Builds, Workflow, Team, ... tabs).

If you chose GitHub when adding your repository, each code change (commit) on GitHub will automatically trigger a Bitrise build.
Otherwise you can find more information about how you can setup a Webhook, to trigger builds
automatically for code push, pull request and tags here.