Skip to content

GitHub setup for organization

Organization level rules are defined by creating a special repository named cm in the organization or group. In this repository, you can add CM automation files, which will apply to all the repositories that gitStream app is connected.

Step 1 of 3: Create a cm repository in your GitHub organization.

Note

Make sure gitStream app is installed for the new cm repository in GitHub.

Step 2 of 3: Create a gitstream.cm rules file in your repository default branch (usually master or main) with the following contents:

Note

Unlike the repository rules, the CM file should be placed in the repository root directory

# -*- mode: yaml -*-
manifest:
  version: 1.0

automations:
  estimated_time_to_review:
    if:
      - true
    run:
      - action: add-label@v1
        args:
          label: "{{ calc.etr }} min review"
          color: {{ 'E94637' if (calc.etr >= 20) else ('FBBD10' if (calc.etr >= 5) else '36A853') }}
  code_experts:
    if: 
      - true
    run:
      - action: add-comment@v1
        args:
          comment: |
            {{ repo | explainCodeExperts(gt=10) }}

calc:
  etr: {{ branch | estimatedReviewTime }}

Step 3 of 3: Create a .github/workflows/gitstream.yml action file in your cm repository default branch (usually master or main) with the following contents:

# Code generated by gitStream GitHub app - DO NOT EDIT

name: gitStream workflow automation

on:
  workflow_dispatch:
    inputs:
      client_payload:
          description: The Client payload
          required: true
      full_repository:
          description: the repository name include the owner in `owner/repo_name` format
          required: true
      head_ref:
          description: the head sha
          required: true
      base_ref:
          description: the base ref 
          required: true
      installation_id:
          description: the installation id
          required: false
      resolver_url:
          description: the resolver url to pass results to
          required: true
      resolver_token:
          description: Optional resolver token for resolver service
          required: false
          default: ''

jobs:
  gitStream:
    timeout-minutes: 5
    runs-on: ubuntu-latest
    name: gitStream workflow automation
    steps:
      - name: Evaluate Rules
        uses: linear-b/gitstream-github-action@v1
        id: rules-engine
        with:
          full_repository: ${{ github.event.inputs.full_repository }}
          head_ref: ${{ github.event.inputs.head_ref }}
          base_ref: ${{ github.event.inputs.base_ref }}
          client_payload: ${{ github.event.inputs.client_payload }}
          installation_id: ${{ github.event.inputs.installation_id }}
          resolver_url: ${{ github.event.inputs.resolver_url }}
          resolver_token: ${{ github.event.inputs.resolver_token }}

Once this step is completed, all your PRs from all your repositories will be processed by this GitHub action in this repo.

Next steps

To learn more on how this works and how to configure it, read here.

Tip

You need to set gitStream as required check for each repository to allow gitStream blocking PRs from merging under certain conditions, set gitStream as required check.

Configuration files

Eventually, the following files should exist in the cm repository:

.
├─ gitstream.cm
├─ .github/
│  └─ workflows/
│     └─ gitstream.yml
File and path Reason
*.cm Under the repo's root directory, any file that ends with .cm will be used by gitStream to specify automation rules, you can edit these files
.github/workflows/gitstream.yml Used by gitStream to execute automation rules in your GitHub repo so source code doesn't get to outside services