Skip to content

Integrate gitStream with GitHub Actions

Dispatch GitHub Actions

Automatically trigger GitHub Actions based on PR content like changed resources, source or target branch, slash commands, and more.

Automatically Dispatch GitHub Actions

Configuration Description

Conditions (all must be true):

  • The PR source or target branch matches a specified format.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions by Branch

# -*- mode: yaml -*-

manifest:
  version: 1.0

on:
  - pr_created
  - commit

automations:
  {% for item in pipelines %}
  # Change pr.target to branch.name if you want to trigger on the source branch rather then the target branch.
  dispatch_github_action_branch_{{ item.name }}:
    if:
      - {{ pr.target | includes(term=item.branch_prefix) }}
    run:
      - action: run-github-workflow@v1
        args:
          workflow: .github/workflows/{{ item.workflow }}
          check_name: {{ item.name }}
      - action: add-label@v1
        args:
          label: {{ item.label }}
  {% endfor %}


pipelines:
  - name: mobile_ci
    label: Mobile CI
    branch_prefix: 'mobile-'
    workflow: mobile.yml
  - name: backend_ci
    label: Backend CI
    branch_prefix: 'backend-'
    workflow: 'backend.yml'

Configuration Description

Conditions (all must be true):

  • The PR has one or more specified labels applied to it.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Using Labels

# -*- mode: yaml -*-

manifest:
  version: 1.0

on:
  - label_added
  - label_removed

automations:
  {% for item in pipelines %}
  dispatch_github_action_label_{{ item.name }}:
    if:
      - {{ pr.labels | match(term=item.label) | some }}
    run:
      - action: run-github-workflow@v1
        args:
          workflow: .github/workflows/{{ item.workflow }}
          check_name: {{ item.name }}
  {% endfor %}

pipelines:
  - name: mobile-ci
    label: Mobile CI
    workflow: mobile.yml
  - name: backend-ci
    label: Backend CI
    workflow: 'backend.yml'

Configuration Description

Conditions (all must be true):

  • The PR modifies one or more specified resources.

Automation Actions:

  • Trigger a manual dispatch for the specified CI pipeline.

Dispatch GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-

manifest:
  version: 1.0

on:
  - pr_created
  - commit

automations:
  {% for item in pipelines %}
  dispatch_github_action_resource_{{ item.name }}:
    if:
      - {{ files | match(list=item.resources) | some }}
    run:
      - action: run-github-workflow@v1
        args:
          workflow: .github/workflows/{{ item.workflow }}
          check_name: {{ item.name }}
      - action: add-label@v1
        args:
          label: {{ item.label }}
  {% endfor %}


pipelines:
  - name: mobile-ci
    label: Mobile CI
    resources:
      - 'src/android/'
      - 'src/ios/'
    workflow: mobile.yml
  - name: backend-ci
    label: Backend CI
    resources:
      - 'src/api/'
      - 'src/services'
    workflow: 'backend.yml'
  - name: frontend-ci
    label: Frontend CI
    resources:
      - 'src/app/'
    workflow: 'frontend.yml'

Skip GitHub Actions

Automatically skip GitHub Actions based on branch names, modified resource, slash commands, and more.

Automatically Skip GitHub Actions

Prerequisite Config for Required Statuses

If you want to skip a required status check, you will need to make sure that your branch protection is configured to allow gitStream to bypass status check requirements.

GitHub Branch Protection Config

Configuration Description

Conditions (all must be true):

  • The target branch name includes a specified keyword. Optionally, you can modify this to detect the source branch name.

Automation Actions:

  • Skip the specified CI pipelines.

Automatically Skip GitHub Actions by Branch

# -*- mode: yaml -*-

manifest:
  version: 1.0

on:
  - pr_created
  - commit

# Optionally, you can change pr.target to branch.name
# if you want to trigger based on the source branch name rather then the target branch name.
automations:
  skip_github_action_branch:
    if:
      - {{ pr.target | includes(term='release') }}
    run:
      - action: add-github-check@v1
        args:
          check_name: staging-ci
          conclusion: skipped
      - action: add-comment@v1
        args:
          comment: |
            [gitStream](https://docs.gitstream.cm) automatically skipped staging CI pipelines because this PR targets the release branch.

Configuration Description

Conditions (all must be true):

  • Someone applies one or more specified labels to a PR.

Automation Actions:

  • Skip the specified CI pipelines.

Use Labels to Automatically Skip GitHub Actions

# -*- mode: yaml -*-

manifest:
  version: 1.0

on:
  - label_added
  - label_removed

automations:
  skip_github_action_label:
    if:
      - {{ pr.labels | match(term='experimental') | some }}
    run:
      - action: add-github-check@v1
        args:
          check_name: production-ci
          conclusion: skipped
      - action: add-comment@v1
        args:
          comment: |
            [gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this is labeled for experimental release.

Configuration Description

Conditions (all must be true):

  • A PR modifies specific files or directories.

Automation Actions:

  • Skip a specified GitHub Action.

Automatically Skip GitHub Actions Based on Modified Resources

# -*- mode: yaml -*-

manifest:
  version: 1.0

on:
  - pr_created
  - commit

automations:
  skip_github_action_resource:
    if:
      - {{ files | match(term='docs/') | every }}
    run:
      - action: add-github-check@v1
        args:
          check_name: release-ci
          conclusion: skipped
      - action: add-github-check@v1
        args:
          check_name: mobile-ci
          conclusion: skipped
      - action: add-comment@v1
        args:
          comment: |
            [gitStream](https://docs.gitstream.cm) automatically skipped production CI pipelines because this PR only contains docs changes.

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

More Automations can be found on the Automation Library and Integrations pages.