diff --git a/docs/automations/integrations/copilot/flag-copilot-pr/README.md b/docs/automations/integrations/copilot/flag-copilot-pr/README.md index a72e4c13..ffb1d407 100644 --- a/docs/automations/integrations/copilot/flag-copilot-pr/README.md +++ b/docs/automations/integrations/copilot/flag-copilot-pr/README.md @@ -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 } + +=== "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" + ``` +
+ + [:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/copilot/label_copilot_by_comment.cm){ .md-button } + +
diff --git a/docs/automations/integrations/copilot/flag-copilot-pr/label-copilot-comment.png b/docs/automations/integrations/copilot/flag-copilot-pr/label-copilot-comment.png new file mode 100644 index 00000000..f237cfe5 Binary files /dev/null and b/docs/automations/integrations/copilot/flag-copilot-pr/label-copilot-comment.png differ diff --git a/docs/downloads/automation-library/integrations/copilot/label_copilot_by_comment.cm b/docs/downloads/automation-library/integrations/copilot/label_copilot_by_comment.cm new file mode 100644 index 00000000..c313cba7 --- /dev/null +++ b/docs/downloads/automation-library/integrations/copilot/label_copilot_by_comment.cm @@ -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/" \ No newline at end of file