Skip to content

Commit 9353efb

Browse files
authored
Merge pull request #6072 from stsewd/docs-automation-rules
Add docs for automatin rules
2 parents a35abde + 25bc3c4 commit 9353efb

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

docs/automation-rules.rst

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
Automation Rules
2+
================
3+
4+
Automation rules allow project maintainers to automate actions on new branches and tags on repositories.
5+
6+
Creating an automation rule
7+
---------------------------
8+
9+
#. Go to your project dashboard
10+
#. Click :guilabel:`Admin` > :guilabel:`Automation Rules`
11+
#. Click on :guilabel:`Add Rule`
12+
#. Fill in the fields
13+
#. Click :guilabel:`Save`
14+
15+
How do they work?
16+
-----------------
17+
18+
When a new tag or branch is pushed to your repository,
19+
Read the Docs creates a new version.
20+
21+
All rules are evaluated for this version, in the order they are listed.
22+
If the version matches the version type and the pattern in the rule,
23+
the specified action is performed on that version.
24+
25+
.. note::
26+
27+
Versions can match multiple rules,
28+
and all matching actions will be performed on the version.
29+
30+
Predefined matches
31+
------------------
32+
33+
Automation rules support several predefined version matches:
34+
35+
- **Any version**: All new versions will match the rule.
36+
- **SemVer versions**: All new versions that follow `semantic versioning <https://semver.org/>`__ will match the rule.
37+
38+
User defined matches
39+
--------------------
40+
41+
If none of the above predefined matches meet your use case,
42+
you can use a **Custom match**.
43+
44+
The custom match should be a valid `Python regular expression <https://docs.python.org/3/library/re.html>`__.
45+
Each new version will be tested against this regular expression.
46+
47+
Actions
48+
-------
49+
50+
When a rule matches a new version, the specified action is performed on that version.
51+
Currently, the following actions are available:
52+
53+
- **Activate version**: Activates and builds the version.
54+
- **Set version as default**: Sets the version as default,
55+
i.e. the version of your project that `/` redirects to.
56+
See more in :ref:`automatic-redirects:Root URL`.
57+
It also activates and builds the version.
58+
59+
.. note::
60+
61+
If your versions follow :pep:`440`,
62+
Read the Docs activates and builds the version if it's greater than the current stable version.
63+
The stable version is also automatically updated at the same time.
64+
See more in :doc:`versions`.
65+
66+
Order
67+
-----
68+
69+
The order your rules are listed in :guilabel:`Admin` > :guilabel:`Automation Rules` matters.
70+
Each action will be performed in that order,
71+
so first rules have a higher priority.
72+
73+
You can change the order using the up and down arrow buttons.
74+
75+
.. note::
76+
77+
New rules are added at the end (lower priority).
78+
79+
Examples
80+
--------
81+
82+
Activate all new tags
83+
~~~~~~~~~~~~~~~~~~~~~
84+
85+
- Match: ``Any version``
86+
- Version type: ``Tag``
87+
- Action: ``Activate version``
88+
89+
Activate only new branches that belong to the ``1.x`` release
90+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91+
92+
- Custom match: ``^1\.\d+$``
93+
- Version type: ``Branch``
94+
- Action: ``Activate version``
95+
96+
Set as default new tags that have the ``-stable`` or ``-release`` suffix
97+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98+
99+
- Custom match: ``-(stable|release)$``
100+
- Version type: ``Tag``
101+
- Action: ``Set version as default``
102+
103+
.. note::
104+
105+
You can also create two rules:
106+
one to match ``-stable`` and other to match ``-release``.
107+
108+
Activate all new tags and branches that start with ``v`` or ``V``
109+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110+
111+
- Custom match: ``^[vV]``
112+
- Version type: ``Tag``
113+
- Action: ``Activate version``
114+
115+
.. Force new line
116+
117+
- Custom match: ``^[vV]``
118+
- Version type: ``Branch``
119+
- Action: ``Activate version``
120+
121+
Activate all new tags that don't contain the ``-nightly`` suffix
122+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123+
124+
.. TODO: update example if https://github.com/readthedocs/readthedocs.org/issues/6354 is approved.
125+
126+
127+
- Custom match: ``.*(?<!-nightly)$``
128+
- Version type: ``Tag``
129+
- Action: ``Activate version``

docs/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ out of your documentation and Read the Docs.
121121
:doc:`User defined redirects <user-defined-redirects>` |
122122
:doc:`Automatic redirects <automatic-redirects>`
123123

124+
* **Versions**
125+
:doc:`Automation rules <automation-rules>`
126+
124127
* **Topic specific guides**:
125128
:doc:`How-to guides <guides/index>`
126129

@@ -142,6 +145,8 @@ out of your documentation and Read the Docs.
142145
user-defined-redirects
143146
automatic-redirects
144147

148+
automation-rules
149+
145150
guides/index
146151

147152
api/index

0 commit comments

Comments
 (0)