Skip to content

Commit

Permalink
Merge pull request #592 from linear-b/copilot-by-code-comment
Browse files Browse the repository at this point in the history
added configurtion to label by code comment
  • Loading branch information
PavelLinearB committed Sep 22, 2024
2 parents 61023f0 + fa91985 commit 582ee31
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/automations/integrations/copilot/flag-copilot-pr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,31 @@ Automatically apply labels to PRs that are assisted by GitHub Copilot. You can a
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/copilot/label_copilot_by_tag.cm){ .md-button }
</span>
</div>

=== "Label by Copilot code comment"

!!! warning "Experimental"
Code generation instructions is an experimental setting wich might change in future GitHub Copilot versions.

Use [Code generation instructions](https://code.visualstudio.com/updates/v1_93#code-generation-instructions) to instruct copilot to add a comment at the beginning of the AI generated code. Use gitStream automation to automatically identify PRs with this comment
![Label by Copilot comment](/automations/integrations/copilot/flag-copilot-pr/label-copilot-comment.png)

!!! info "Configuration Description"
Conditions:

* The comment `Generated by Copilot` is added to the code in this PR

Automation Actions:

* Apply a `🤖 Copilot` label to the PR

!!! example "Label Copilot by comment"
```yaml+jinja
--8<-- "docs/downloads/automation-library/integrations/copilot/label_copilot_by_comment.cm"
```
<div class="result" markdown>
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/copilot/label_copilot_by_comment.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,16 @@
-*- mode: yaml -*-

manifest:
version: 1.0

automations:
label_copilot_pr:
# Look for the comment 'Generated by Copilot' in the added code
if:
- {{ source.diff.files | matchDiffLines(regex=copilot_comment, ignoreWhiteSpaces=true) | some }}
run:
- action: add-label@v1
args:
label: '🤖 Copilot'

copilot_comment: "r/^\\+.*Generated by Copilot/"

0 comments on commit 582ee31

Please sign in to comment.