Dispatch GitHub Actions
Automatically trigger GitHub Actions based on PR content like changed resources, source or target branch, slash commands, and more.
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'
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.
Related Automations:
- Automatically approve changes to docs, tests, and other safe assets.
- Approve low-risk PRs from trusted teams.
- Approve Python or JavaScript formatting changes.
- Approve Tiny Changes
- Approve JSDoc or Javadoc changes.
- Approve and Merge Dependabot PRs
More Automations can be found on the Automation Library and Integrations pages.