| title | How to Setup gitStream with GitHub |
|---|---|
| description | Install gitStream to your GitHub organization. |
!!! Warning "Install gitStream"
Before you can complete the gitStream setup process, you need to install the gitStream app to your [GitHub organization](https://github.com/apps/gitstream-cm/installations/new){ .md-button }.
You can set up gitStream for a single repo or your entire GitHub organization. Select the tab below for the instructions you want. === "Single Repo" Single Repo Setup
You must implement two main components for gitStream to function for a single GitHub repo. The first is a configuration file that defines the workflow automations to execute for the repo. The second is a GitHub actions configuration file that triggers gitStream when PRs are created or updated.
!!! example "Required Configurations"
**gitStream**
Create a `.cm/gitstream.cm` rules file in your repository's default branch (usually `master` or `main`). This file will contain a YAML configuration that determines the workflows that run on the repo, and you can name it anything you want as long as it ends in `.cm`
Here is an example of a gitStream configuration file you can use to setup some basic workflow automations.
```yaml+jinja
--8<-- "docs/downloads/gitstream.cm"
```
**Github Actions**
Once your gitStream configuration file is setup, you need a Github Actions configuration file to trigger gitStream automations. Create a `.github/workflows/gitstream.yml` file in your repository's default branch (usually `master` or `main`) and add the following configuration:
```yaml+jinja
--8<-- "docs/downloads/gitstream.yml"
```
!!! Success
When finished, you should have the following file structure in your repo.
```
.
├─ .cm/
│ └─ gitstream.cm
├─ .github/
│ └─ workflows/
│ └─ gitstream.yml
```
=== "GitHub Organization" GitHub Organization Setup
Organization rules are ideal when you want to enforce consistent rules across every repo in your organization. You can define them by creating a special repository named `cm` in your GitHub organization where you can add automation files that will apply to **all** repositories within that organization.
!!! Tip "Prerequisite: Create a cm repo and enable gitStream."
Organization-wide automations need to be defined in a repo named "cm" inside your GitHub organization. Before continuing, you must create this repo and <a href="https://github.com/apps/gitstream-cm/installations/new" target="_blank">enable the gitStream app for it</a>.
!!! example "Required Configurations"
**gitStream**
Create a `gitstream.cm` rules file in the root directory of your cm repository's default branch (usually `master` or `main`). This file will contain a YAML configuration that determines the workflows that run on your organization's repos. You can name it anything you want as long as it ends in `.cm`
!!! info "Configuration files go in the repo's root directory."
Unlike the set up instructions for a single repo, your `.cm` files should be placed in the repository's root directory.
```yaml+jinja
--8<-- "docs/downloads/gitstream.cm"
```
**GitHub Actions**
Once your gitStream configuration file is set up, you will need to create a Github Actions configuration file to trigger gitStream automations. Create a `.github/workflows/gitstream.yml` file in your `cm` repository's default branch (usually `master` or `main`) and add the following configuration:
```yaml+jinja
--8<-- "docs/downloads/gitstream.yml"
```
!!! Success
Once finished, **all** PRs to your organization's repositories will be processed by the GitHub Action in this repo, and your `cm` repo should have a file directory that looks like this.
```
.
├─ gitstream.cm
├─ .github/
│ └─ workflows/
│ └─ gitstream.yml
```
!!! info "gitStream will now do these two things."
When a PR is created or changed, apply or update a label that provides an estimated time to review.

When a new PR is created, comment with a list of code experts.

!!! tip "How gitStream Works" Read our guide: How gitStream Works to get an overview of the gitStream syntax and automation lifecycle.
| Permissions | Reason |
|---|---|
| Write access to dedicated gitStream app files | Used to set up the gitStream workflow files |
| Write access to code | To allow gitStream to approve PRs once all conditions are met |
| Read access to administration, issues, and metadata | To get the user team membership, and branch protection settings |
| Read and write access to actions, checks, pull requests, and workflows | Trigger workflows, create and update pull requests and their checks, and modify workflow files |
| User email | Used to identify users |
You can configure Github to require gitStream checks to pass before PRs can be merged using branch protection rules.
!!! info "Run a gitStream check before continuing" You need to run a check using your gitStream configuration at least once before it can be set as a required check. Make sure to open at least 1 PR before doing this setting.
Here are the steps to configure gitStream in your repo's branch protection rules.
- Go to repo
settings - On the left panel select
Code and automation>Branches - Set
Branch protection rulesfor your desired branch - Enable
Require status checks to pass before merging - Search for
status checks in the last week for this repository - Select
gitStream.cmas required check
Configure in your GitHub organization{ .md-button }, and choose Uninstall "gitStream.cm"

