Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New slash command examples #432

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,30 @@ Automatically trigger GitHub Actions based on PR content like changed resources,
</span>
</div>
</div>

=== "Using Slash Commands"
Automatically dispatch gitHub actions workflow by using slash commands.

!!! info "Configuration Description"

**Conditions (all must be true):**

* The PR has a comment that contains the text '/gitstream dispatch <action-name>'.

**Automation Actions:**

* Dispatch the Github action workflow specified in the command.

<div class="automationExample" markdown="1">
!!! example "Dispatch GitHub Actions Using Slash Commands"
```yaml+jinja
--8<-- "docs/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_slash_command.cm"
```
<div class="result" markdown>
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/github-actions/dispatch-github-action/dispatch_github_action_slash_command.cm){ .md-button }
</span>
</div>
<!-- --8<-- [end:example]-->

## Additional Resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,67 @@ description: Automatically assign PR reviewers based on code expertise.
# Assign Code Experts

<!-- --8<-- [start:example]-->
When someone applies a `suggest-reviewers` label to a PR, use codeExperts to assign recommended reviewers and post a comment with the `explainCodeExperts` automation action.

<div class="automationImage" style="align:right" markdown="1">
![Assign Code Experts](/automations/standard/review-assignment/assign-code-experts/assign_code_experts.png)
</div>
<div class="automationDescription" markdown="1">
!!! info "Configuration Description"
Conditions (all must be true):

* The PR has a suggest-reviewers label attached to it.

Automation Actions:

* Use `codeExperts` to assign recommended reviewers.
* Use `explainCodeExperts` to post a comment that lists the top code experts for the PR.
</div>
<div class="automationExample" markdown="1">
!!! example "Assign Code Experts"
```yaml+jinja
--8<-- "docs/downloads/automation-library/standard/review-assignment/assign_code_experts.cm"
```
<div class="result" markdown="1">
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/standard/review-assignment/assign_code_experts.cm){ .md-button }
</span>
=== "Using Labels"
When someone applies a `suggest-reviewers` label to a PR, use codeExperts to assign recommended reviewers and post a comment with the `explainCodeExperts` automation action.

<div class="automationImage" style="align:right" markdown="1">
![Assign Code Experts](/automations/standard/review-assignment/assign-code-experts/assign_code_experts.png)
</div>
<div class="automationDescription" markdown="1">
!!! info "Configuration Description"
Conditions (all must be true):

* The PR has a suggest-reviewers label attached to it.

Automation Actions:

* Use `codeExperts` to assign recommended reviewers.
* Use `explainCodeExperts` to post a comment that lists the top code experts for the PR.
</div>
<div class="automationExample" markdown="1">
!!! example "Assign Code Experts"
```yaml+jinja
--8<-- "docs/downloads/automation-library/standard/review-assignment/assign_code_experts.cm"
```
<div class="result" markdown="1">
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/standard/review-assignment/assign_code_experts.cm){ .md-button }
</span>
</div>
</div>
</div>

=== "Using Slash Commands"
Automatically Auto-assign code experts as reviewers using slash commands.

![Review Auto-assign Slash Command](/automations/standard/review-assignment/assign-code-experts/assign-code-experts-slash-command.png)

!!! info "Configuration Description"

**Conditions (all must be true):**

* The PR has a comment that contains the text '/gitstream auto-assign'.

**Automation Actions:**

* Assign the top two code experts for the PR as reviewers.

<div class="automationExample" markdown="1">
!!! example "Auto-assign Reviewers Using a Slash Command"
```yaml+jinja
--8<-- "docs/downloads/automation-library/standard/review-assignment/assign_expert_slash_command.cm"
```
<div class="result" markdown>
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/standard/review-assignment/assign_expert_slash_command.cm){ .md-button }
</span>
</div>
<!-- --8<-- [end:example]-->
## Additional Resources

--8<-- "docs/snippets/general.md"

**Related Automations**:

--8<-- "docs/snippets/review-assignment-automation.md::1"
--8<-- "docs/snippets/review-assignment-automation.md:3:"
--8<-- "docs/snippets/general.md"

--8<-- "docs/snippets/automation-footer.md"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: gitStream Automation - Auto-assign Reviewers Using a Slash Command.
description: Automatically Auto-assign reviewers using a slash command.
---
# Auto-assign Reviewers Using a Slash Command

<!-- --8<-- [start:example]-->
Automatically Auto-assign reviewers using a slash command.

![Review Auto-assign Slash Command](/automations/standard/slash-commands/review-auto-assign-slash-command/review-auto-assign-slash-command.png)

!!! info "Configuration Description"

**Conditions (all must be true):**

* The PR has a comment that contains the term '/gitstream auto-assign'.

**Automation Actions:**

* Dispatch the Github action workflow mentioned in the term.

<div class="automationExample" markdown="1">
!!! example "Auto-assign Reviewers Using a Slash Command"
```yaml+jinja
--8<-- "docs/downloads/automation-library/standard/slash-commands/review-auto-assign-slash-command/review_auto_assign_slash_command.cm"
```
<div class="result" markdown>
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/standard/slash-commands/review-auto-assign-slash-command/review_auto_assign_slash_command.cm){ .md-button }
</span>
</div>
<!-- --8<-- [end:example]-->

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: gitStream Automation - Dispatch GitHub Actions Based on a Slash Command
description: Automatically dispatch gitHub actions workflow based on a slash command.
---
# Review Slash Commands and Dispatch GitHub Actions

<!-- --8<-- [start:example]-->
Automatically dispatch gitHub actions workflow based on a slash command.

![Review GitHub Actions Slash Command](/automations/standard/slash-commands/review-dispatch-github-action-slash-command/review-dispatch-github-action-slash-command.png)

!!! info "Configuration Description"

**Conditions (all must be true):**

* The PR has a comment that contains the term '/gitstream dispatch <action-name>'.

**Automation Actions:**

* Dispatch the Github action workflow mentioned in the term.

<div class="automationExample" markdown="1">
!!! example "Review Slash Commands and Dispatch GitHub Actions"
```yaml+jinja
--8<-- "docs/downloads/automation-library/standard/slash-commands/review-dispatch-github-action-slash-command/review_dispatch_github_action_slash_command.cm"
```
<div class="result" markdown>
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/standard/slash-commands/review-dispatch-github-action-slash-command/review_dispatch_github_action_slash_command.cm){ .md-button }
</span>
</div>
<!-- --8<-- [end:example]-->

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- mode: yaml -*-

manifest:
version: 1.0

on:
- comment_added

automations:
{% for item in pipelines %}
dispatch_github_action_{{ item.name }}:
if:
- {{ pr.comments | match(attr='content', term=item.command) | some }}
run:
- action: run-github-workflow@v1
args:
workflow: .github/workflows/{{ item.workflow }}
check_name: {{ item.name }}
- action: add-label@v1
args:
label: {{ item.name }}
{% endfor %}

pipelines:
- name: mobile-ci
command: '/gitstream ci-mobile'
resources:
- 'src/android/'
- 'src/ios/'
workflow: mobile.yml
- name: backend-ci
command: '/gitstream ci-backend'
resources:
- 'src/api/'
- 'src/services'
workflow: 'backend.yml'
- name: frontend-ci
command: '/gitstream ci-frontend'
resources:
- 'src/app/'
workflow: 'frontend.yml'
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- mode: yaml -*-

manifest:
version: 1.0

on:
- comment_added

automations:
assign_expert_slash_command:
if:
- {{ is.requested }}
run:
- action: add-reviewers@v1
args:
reviewers: {{ repo | codeExperts(gt=10) }}
- action: explain-code-experts@v1
args:
gt: 10
is:
requested: {{ pr.comments | match(attr='content', term='/gitstream auto-assign') | some }}