-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Docs: Split "Automation rules" into reference and how-to (Diátaxis) #9953
Changes from all commits
37cf0d6
ed6279d
0c3c136
b4d4922
8205542
c0c3a7f
bf47743
2ca75eb
972eb98
280b837
0671993
0767f59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,110 @@ | ||
Automation Rules | ||
Automation rules | ||
================ | ||
|
||
Automation rules allow project maintainers to automate actions on new branches and tags on repositories. | ||
Automation rules allow project maintainers to automate actions on new branches and tags in Git repositories. | ||
If you are familiar with :term:`GitOps`, | ||
this might seem familiar. | ||
The goal of automation rules is to be able to control versioning through your Git repository | ||
and avoid duplicating these efforts on Read the Docs. | ||
|
||
Creating an automation rule | ||
--------------------------- | ||
.. seealso:: | ||
|
||
#. Go to your project dashboard | ||
#. Click :guilabel:`Admin` > :guilabel:`Automation Rules` | ||
#. Click on :guilabel:`Add Rule` | ||
#. Fill in the fields | ||
#. Click :guilabel:`Save` | ||
:doc:`/guides/automation-rules` | ||
A practical guide to managing automated versioning of your documentation. | ||
|
||
How do they work? | ||
----------------- | ||
:doc:`/versions` | ||
General explanation of how versioning works on Read the Docs | ||
|
||
How automation rules work | ||
------------------------- | ||
|
||
When a new tag or branch is pushed to your repository, | ||
Read the Docs creates a new version. | ||
Read the Docs receives a webhook. | ||
We then create a new Read the Docs *version* that matches your new Git *tag or branch*. | ||
|
||
All rules are evaluated for this version, in the order they are listed. | ||
If the version matches the version type and the pattern in the rule, | ||
the specified action is performed on that version. | ||
All automation rules are evaluated for this version, | ||
in the order they are listed. | ||
If the version **matches** the version type and the pattern in the rule, | ||
the specified **action** is performed on that version. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A diagram would be great here in the future, but probably too much for this refactor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we can establish a quick way to use Mermaid diagrams, this would definitely be a valid option. Last time, I hit some issues that would need to be solved, so ended up generating Mermaid.js and saving as PNG "by hand" which was a bit too cumbersome for a "quick diagram". |
||
|
||
.. _TODO: A diagram would be great here in the future, but probably too much for this refactor. | ||
|
||
.. note:: | ||
|
||
Versions can match multiple rules, | ||
Versions can match multiple automation rules, | ||
and all matching actions will be performed on the version. | ||
|
||
Matching a version in Git | ||
------------------------- | ||
|
||
We have a couple predefined ways to match against versions that are created, | ||
and you can also define your own. | ||
|
||
Predefined matches | ||
------------------ | ||
~~~~~~~~~~~~~~~~~~ | ||
|
||
Automation rules support several predefined version matches: | ||
Automation rules support two predefined version matches: | ||
|
||
- **Any version**: All new versions will match the rule. | ||
- **SemVer versions**: All new versions that follow `semantic versioning <https://semver.org/>`__ will match the rule. | ||
|
||
User defined matches | ||
-------------------- | ||
Custom matches | ||
~~~~~~~~~~~~~~ | ||
|
||
If none of the above predefined matches meet your use case, | ||
you can use a **Custom match**. | ||
|
||
The custom match should be a valid `Python regular expression <https://docs.python.org/3/library/re.html>`__. | ||
Each new version will be tested against this regular expression. | ||
|
||
Actions | ||
------- | ||
Actions for versions | ||
-------------------- | ||
|
||
When a rule matches a new version, the specified action is performed on that version. | ||
When an automation rule matches a new version, | ||
the specified action is performed on that version. | ||
Currently, the following actions are available: | ||
|
||
- **Activate version**: Activates and builds the version. | ||
- **Hide version**: Hides the version. If the version is not active, activates it and builds the version. | ||
See :ref:`versions:Version States`. | ||
- **Make version public**: Sets the version's privacy level to public. | ||
See :ref:`versions:privacy levels`. | ||
- **Make version private**: Sets the version's privacy level to private. | ||
See :ref:`versions:privacy levels`. | ||
- **Set version as default**: Sets the version as default, | ||
i.e. the version of your project that `/` redirects to. | ||
See more in :ref:`automatic-redirects:Root URL`. | ||
It also activates and builds the version. | ||
- **Delete version**: When a branch or tag is deleted from your repository, | ||
Read the Docs will delete it *only if isn't active*. | ||
This action allows you to delete *active* versions when a branch or tag is deleted from your repository. | ||
Activate version | ||
Activates and builds the version. | ||
|
||
.. note:: | ||
Hide version | ||
Hides the version. If the version is not active, activates it and builds the version. | ||
See :ref:`versions:Version states`. | ||
|
||
The default version isn't deleted even if it matches a rule. | ||
You can use the ``Set version as default`` action to change the default version | ||
before deleting the current one. | ||
Make version public | ||
Sets the version's privacy level to public. | ||
See :ref:`versions:Privacy levels`. | ||
|
||
Make version private | ||
Sets the version's privacy level to private. | ||
See :ref:`versions:Privacy levels`. | ||
|
||
.. note:: | ||
|
||
If your versions follow :pep:`440`, | ||
Read the Docs activates and builds the version if it's greater than the current stable version. | ||
The stable version is also automatically updated at the same time. | ||
See more in :doc:`versions`. | ||
Set version as default | ||
Sets the version as the :term:`default version`. | ||
benjaoming marked this conversation as resolved.
Show resolved
Hide resolved
|
||
It also activates and builds the version. | ||
See :ref:`automatic-redirects:Root URL`. | ||
|
||
Order | ||
----- | ||
Delete version | ||
When a branch or tag is deleted from your repository, | ||
Read the Docs will delete it *only if isn't active*. | ||
This action allows you to delete *active* versions when a branch or tag is deleted from your repository. | ||
|
||
The order your rules are listed in :guilabel:`Admin` > :guilabel:`Automation Rules` matters. | ||
Each action will be performed in that order, | ||
so first rules have a higher priority. | ||
There are a couple caveats to these rules that are useful: | ||
|
||
You can change the order using the up and down arrow buttons. | ||
* The :term:`default version` isn't deleted even if it matches a rule. | ||
You can use the ``Set version as default`` action to change the default version | ||
before deleting the current one. | ||
* If your versions follow :pep:`440`, | ||
Read the Docs activates and builds the version if it's greater than the current stable version. | ||
The stable version is also automatically updated at the same time. | ||
See more in :doc:`versions`. | ||
|
||
.. note:: | ||
Order | ||
----- | ||
|
||
New rules are added at the end (lower priority). | ||
When a new Read the Docs version is created, | ||
all rules with a successful match will have their action triggered, | ||
in the order they appear on the :guilabel:`Automation Rules` page. | ||
|
||
Examples | ||
-------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
How to manage versions automatically | ||
==================================== | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This title is great to improve with the user's problem in mind. |
||
|
||
In this guide, | ||
we show you how to define rules to automate creation of new versions on Read the Docs, | ||
using your Git repository's version logic. | ||
Automating your versioning on Read the Docs means you only have to handle your versioning logic in Git. | ||
|
||
.. seealso:: | ||
|
||
:doc:`/versions` | ||
Learn more about versioning of documentation in general. | ||
|
||
:doc:`/automation-rules` | ||
Reference for all different rules and actions possible with automation. | ||
|
||
Adding a new automation rule | ||
---------------------------- | ||
|
||
First you need to go to the automation rule creation page: | ||
|
||
#. Navigate to :menuselection:`Admin --> Automation Rules`. | ||
#. Click on :guilabel:`Add Rule` and you will see the following form. | ||
|
||
.. image:: /img/screenshot_automation_rules_add.png | ||
:alt: Screenshot of the "Add Rule" form | ||
|
||
In the :guilabel:`Automation Rule` form, you need to fill in 4 fields: | ||
|
||
#. Enter a :guilabel:`Description` that you can refer to later. | ||
For example, entering "Create new stable version" is a good title, | ||
as it explains the intention of the rule. | ||
|
||
#. Choose a :guilabel:`Match`, | ||
which is the pattern you wish to detect in either a Git branch or tag. | ||
|
||
* :ref:`Any version <automation-rules:Predefined matches>` matches all values. | ||
* :ref:`SemVer versions <automation-rules:Predefined matches>` matches only values that have the `SemVer`_ format. | ||
* :ref:`Custom match <automation-rules:User defined matches>` matches your own pattern (entered below). | ||
If you choose this option, | ||
a field :guilabel:`Custom match` will automatically appear below the drop-down where you can add a regular expression in `Python regex format`_. | ||
|
||
#. Choose a :guilabel:`Version type`. | ||
You can choose between *Tag* or *Branch*, | ||
denoting *Git tag* or *Git branch*. | ||
|
||
#. Finally, choose the :guilabel:`Action`: | ||
|
||
* :ref:`Activate version <automation-rules:Actions for versions>` | ||
* :ref:`Hide version <automation-rules:Actions for versions>` | ||
* :ref:`Set version as default <automation-rules:Actions for versions>` | ||
* :ref:`Delete version (on branch/tag deletion) <automation-rules:Actions for versions>` | ||
|
||
|
||
Now your rule is ready and you can press :guilabel:`Save`. | ||
The rule takes effect immediately when a new version is created, | ||
but does not apply to old versions. | ||
|
||
.. tip:: | ||
|
||
Examples of common usage | ||
See :ref:`the list of examples <automation-rules:Examples>` for rules that are commonly used. | ||
|
||
Want to test if your rule works? | ||
If you are using Git in order to create new versions, | ||
create a Git tag or branch that matches the rule and check if your automation action is triggered. | ||
After the experiment, | ||
you can delete both from Git and Read the Docs. | ||
|
||
.. _Python regex format: https://docs.python.org/3/library/re.html | ||
.. _SemVer: https://semver.org/ | ||
|
||
Ordering your rules | ||
------------------- | ||
|
||
The order your rules are listed in :menuselection:`Admin --> Automation Rules` matters. | ||
Each action will be performed in that order, | ||
so earlier rules have a higher priority. | ||
|
||
You can change the order using the up and down arrow buttons. | ||
|
||
.. note:: | ||
|
||
New rules are added at the end (lower priority). |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,6 @@ Features | |
analytics | ||
/feature-flags | ||
/server-side-search/index | ||
/automation-rules | ||
/user-defined-redirects | ||
/badges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha just read this again and realized that it sounds a lot like "automation rules [verb]"
Maybe that'll make people click it, anyways :)