You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cm-file.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,65 @@ By utilizing the following techniques, you can effectively combine and manage gl
79
79
2. To exclude or run only on specific repositories from a global rule, you can use `triggers.include.repository` and `triggers.exclude.repository` in the `cm` file and add a list of the unwanted or wanted repositories respectfully.
80
80
3. To override a global rule for specific automation in a repository, you can duplicate the rule (both the file and automation name) and place it in the desired repository. The locally defined rule will then take precedence over the global rule for that specific repository.
81
81
82
+
### Controlling Organization-Level Rules per Repository
83
+
84
+
The `triggers` section in organization-level rules allows you to precisely control which repositories will run specific automations. This is particularly useful for implementing standardized rules across most repositories while exempting specific ones, or for creating specialized automations that only apply to certain repository types.
85
+
86
+
#### Repository Inclusion and Exclusion
87
+
88
+
You can use `triggers.include.repository` and `triggers.exclude.repository` to define which repositories should or should not run particular automations:
89
+
90
+
```yaml+jinja
91
+
# In your organization's 'cm' repository
92
+
manifest:
93
+
version: 1.0
94
+
95
+
# This automation will run on all repositories EXCEPT those containing 'legacy' in their name
96
+
triggers:
97
+
exclude:
98
+
repository:
99
+
- r/legacy/
100
+
101
+
automations:
102
+
enforce_pr_title_format:
103
+
if:
104
+
- {{ not (pr.title | includes(term="fix:|feat:|docs:|style:|refactor:|test:|chore:")) }}
105
+
run:
106
+
- action: add-comment@v1
107
+
args:
108
+
comment: |
109
+
Please format your PR title according to our [Conventional Commits](https://www.conventionalcommits.org/) standard.
110
+
Example: `feat: implement new login flow`
111
+
```
112
+
113
+
#### Creating Repository-Type Specific Rules
114
+
115
+
You can also create separate CM files for different types of repositories:
116
+
117
+
```yaml+jinja
118
+
# backend-rules.cm in your organization's 'cm' repository
119
+
manifest:
120
+
version: 1.0
121
+
122
+
# This file's automations will ONLY run on repositories with 'api' or 'service' in their name
123
+
triggers:
124
+
include:
125
+
repository:
126
+
- r/api|service/
127
+
128
+
automations:
129
+
require_api_docs:
130
+
if:
131
+
- {{ files | match(regex=r/\/api\/.*\.js|ts$/) | some }}
132
+
run:
133
+
- action: request-changes@v1
134
+
args:
135
+
comment: |
136
+
API changes detected. Please ensure you've updated the corresponding documentation.
137
+
```
138
+
139
+
This approach allows you to create specialized rule sets for different repository types (frontend, backend, infrastructure, etc.) while maintaining them all in a centralized location.
0 commit comments