Skip to content

Commit a008068

Browse files
Docs: Split and relabel VCS integration as explanation and how-to (Diátaxis) (#9675)
* Re-label VCS integration as a how-to guide and let's call it "Git platform integration"? * Revert back to saying VCS (to cut short discussion) * Revert another change, just to reduce distractions * WIP: Splitting up and updating VCS integration * Update references to integrations after the split * Remove the generic framing of VCS providers * Add git integrations to the list of explanations * Add a local table of content, move oddly placed instructions, fixup broken headline levels * Remove local TOC, move individual provider guides to tabs * Makes it possible to open up a tab using a sphinx label reference * Move Debugging Webhooks into Troubleshooting * Remove section Resyncing webhooks * Comment about scope * Update docs/user/integrations.rst Co-authored-by: Eric Holscher <[email protected]> * WIP * Adds a draft of explanation of how continuous documentation fits into the landscape * Apply suggestions from code review @ericholscher Co-authored-by: Eric Holscher <[email protected]> * Update docs/user/integrations.rst * Add explanation about versioning and a seealso for Automation Rules * Tweak the Automated Versioning subsection and add a seealso for the flyout menu * Refinements to versioning subsection * Update docs/user/integrations.rst Co-authored-by: Eric Holscher <[email protected]> * Remove paragraph that already had a broken reference (even before AFAICT) and that does not lead to clear solutions * Make Git a proper noun. This way of writing "Git repository" etc. is widely used, example: https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository. Ref #9813 Co-authored-by: Eric Holscher <[email protected]>
1 parent 09e75e6 commit a008068

File tree

5 files changed

+282
-211
lines changed

5 files changed

+282
-211
lines changed

docs/_static/js/expand_tabs.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
/*
22
* Expands a specific tab of sphinx-tabs.
33
* Usage:
4-
* - docs.readthedocs.io/?tab=Name
5-
* - docs.readthedocs.io/?tab=Name#section
6-
* Where 'Name' is the title of the tab (case sensitive).
4+
* 1) docs.readthedocs.io/?tab=Name
5+
* 2) docs.readthedocs.io/?tab=Name#section
6+
* 3) docs.readthedocs.io/page#sphinx-label
7+
* In 1) and 2), 'Name' is the title of the tab (case sensitive).
8+
*
9+
* In 3), you need to add a sphinx reference inside the tab.
10+
* It mimics how sections are referenced and can be refactored.
711
*/
812
$( document ).ready(function() {
913
const urlParams = new URLSearchParams(window.location.search);
@@ -14,4 +18,20 @@ $( document ).ready(function() {
1418
tab.click();
1519
}
1620
}
21+
22+
// Uses a hash referencing a Sphinx label from the URL page#sphinx-label
23+
var hash = window.location.hash.substr(1);
24+
hash = hash.replace(/[^0-9a-z\-_]/gi, '');
25+
// If the hash is inside a tab panel
26+
var tab_with_reference = $(".sphinx-tabs-panel #" + hash).parents(".sphinx-tabs-panel");
27+
28+
if (tab_with_reference.length > 0) {
29+
// Use the panel's ID to guess the tab's ID
30+
var panel_id = tab_with_reference.first().attr("id");
31+
var tab_id = panel_id.replace("panel-", "tab-");
32+
// Invoke the tab buttons click() method to display it
33+
$("button#" + tab_id).click();
34+
// Scroll the tab widget into view
35+
$('html, body').animate({ scrollTop: tab_with_reference.parents(".sphinx-tabs").first().offset().top}, 1000);
36+
}
1737
});

docs/user/guides/administrators.rst

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ have a look at our :doc:`/tutorial/index`.
1212
.. toctree::
1313
:maxdepth: 1
1414

15+
Connect your git repository <git-integrations>
1516
Manage Custom Domains <custom-domains>
1617
Enable Canonical URLs <canonical-urls>
1718
technical-docs-seo-guide

docs/user/guides/git-integrations.rst

+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
How to manually connect your Git repository
2+
===========================================
3+
4+
In this guide, you will find the simple steps to integrating your Read the Docs project with GitHub, Bitbucket, GitLab, Gitea or any other Git provider that supports our generic API.
5+
6+
.. note::
7+
8+
If your account is connected to the provider,
9+
we'll try to setup the integration automatically.
10+
If something fails, you can still setup the integration manually.
11+
12+
13+
Provider-specific instructions
14+
------------------------------
15+
16+
.. tabs::
17+
18+
.. tab:: GitHub
19+
20+
.. _webhook-integration-github:
21+
22+
* Go to the :guilabel:`Settings` page for your **GitHub project**
23+
* Click :guilabel:`Webhooks` > :guilabel:`Add webhook`
24+
* For **Payload URL**, use the URL of the integration on your **Read the Docs project**,
25+
found on the project's :guilabel:`Admin` > :guilabel:`Integrations` page.
26+
You may need to prepend *https://* to the URL.
27+
* For **Content type**, both *application/json* and
28+
*application/x-www-form-urlencoded* work
29+
* Leave the **Secrets** field blank
30+
* Select **Let me select individual events**,
31+
and mark **Branch or tag creation**, **Branch or tag deletion**, **Pull requests** and **Pushes** events
32+
* Ensure **Active** is enabled; it is by default
33+
* Finish by clicking **Add webhook**. You may be prompted to enter your GitHub password to confirm your action.
34+
35+
You can verify if the webhook is working at the bottom of the GitHub page under **Recent Deliveries**.
36+
If you see a Response 200, then the webhook is correctly configured.
37+
For a 403 error, it's likely that the Payload URL is incorrect.
38+
39+
.. note:: The webhook token, intended for the GitHub **Secret** field, is not yet implemented.
40+
41+
.. tab:: Bitbucket
42+
43+
.. _webhook-integration-bitbucket:
44+
45+
* Go to the :guilabel:`Settings` > :guilabel:`Webhooks` > :guilabel:`Add webhook` page for your project
46+
* For **URL**, use the URL of the integration on Read the Docs,
47+
found on the :guilabel:`Admin` > :guilabel:`Integrations` page
48+
* Under **Triggers**, **Repository push** should be selected
49+
* Finish by clicking **Save**
50+
51+
.. tab:: GitLab
52+
53+
.. _webhook-integration-gitlab:
54+
55+
* Go to the :guilabel:`Settings` > :guilabel:`Webhooks` page for your GitLab project
56+
* For **URL**, use the URL of the integration on **Read the Docs project**,
57+
found on the :guilabel:`Admin` > :guilabel:`Integrations` page
58+
* Leave the default **Push events** selected,
59+
additionally mark **Tag push events** and **Merge request events**.
60+
* Finish by clicking **Add Webhook**
61+
62+
.. tab:: Gitea
63+
64+
These instructions apply to any Gitea instance.
65+
66+
.. warning::
67+
68+
This isn't officially supported, but using the "GitHub webhook" is an effective workaround,
69+
because Gitea uses the same payload as GitHub. The generic webhook is not compatible with Gitea.
70+
See `issue #8364`_ for more details. Official support may be implemented in the future.
71+
72+
On Read the Docs:
73+
74+
* Manually create a "GitHub webhook" integration
75+
(this will show a warning about the webhook not being correctly set up,
76+
that will go away when the webhook is configured in Gitea)
77+
78+
On your Gitea instance:
79+
80+
* Go to the :guilabel:`Settings` > :guilabel:`Webhooks` page for your project on your Gitea instance
81+
* Create a new webhook of type "Gitea"
82+
* For **URL**, use the URL of the integration on Read the Docs,
83+
found on the :guilabel:`Admin` > :guilabel:`Integrations` page
84+
* Leave the default **HTTP Method** as POST
85+
* For **Content type**, both *application/json* and
86+
*application/x-www-form-urlencoded* work
87+
* Leave the **Secret** field blank
88+
* Select **Choose events**,
89+
and mark **Branch or tag creation**, **Branch or tag deletion** and **Push** events
90+
* Ensure **Active** is enabled; it is by default
91+
* Finish by clicking **Add Webhook**
92+
* Test the webhook with :guilabel:`Delivery test`
93+
94+
Finally, on Read the Docs, check that the warnings have disappeared
95+
and the delivery test triggered a build.
96+
97+
.. _issue #8364: https://github.com/readthedocs/readthedocs.org/issues/8364
98+
99+
100+
Additional integration
101+
----------------------
102+
103+
You can configure multiple webhooks.
104+
105+
To manually set up an integration, go to :guilabel:`Admin` > :guilabel:`Integrations` > :guilabel:`Add integration`
106+
dashboard page and select the integration type you'd like to add.
107+
After you have added the integration, you'll see a link to information about the integration.
108+
109+
As an example, the URL pattern looks like this: ``https://readthedocs.org/api/v2/webhook/<project-name>/<id>/*``.
110+
111+
Use this URL when setting up a new integration with your provider ^^ these steps vary depending on the provider.
112+
113+
114+
.. _webhook-integration-generic:
115+
116+
Using the generic API integration
117+
---------------------------------
118+
119+
For repositories that are not hosted with a supported provider, we also offer a
120+
generic API endpoint for triggering project builds. Similar to webhook integrations,
121+
this integration has a specific URL, which can be found on the project's **Integrations** dashboard page
122+
(:guilabel:`Admin` > :guilabel:`Integrations`).
123+
124+
Token authentication is required to use the generic endpoint, you will find this
125+
token on the integration details page. The token should be passed in as a
126+
request parameter, either as form data or as part of JSON data input.
127+
128+
Parameters
129+
^^^^^^^^^^
130+
131+
This endpoint accepts the following arguments during an HTTP POST:
132+
133+
branches
134+
The names of the branches to trigger builds for. This can either be an array
135+
of branch name strings, or just a single branch name string.
136+
137+
Default: **latest**
138+
139+
token
140+
The integration token found on the project's **Integrations** dashboard page
141+
(:guilabel:`Admin` > :guilabel:`Integrations`).
142+
143+
For example, the cURL command to build the ``dev`` branch, using the token
144+
``1234``, would be::
145+
146+
curl -X POST -d "branches=dev" -d "token=1234" https://readthedocs.org/api/v2/webhook/example-project/1/
147+
148+
A command like the one above could be called from a cron job or from a hook
149+
inside Git_, Subversion_, Mercurial_, or Bazaar_.
150+
151+
.. _Git: http://www.kernel.org/pub/software/scm/git/docs/githooks.html
152+
.. _Subversion: https://www.mikewest.org/2006/06/subversion-post-commit-hooks-101
153+
.. _Mercurial: http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html
154+
.. _Bazaar: http://wiki.bazaar.canonical.com/BzrHooks
155+
156+
Authentication
157+
^^^^^^^^^^^^^^
158+
159+
This endpoint requires authentication. If authenticating with an integration
160+
token, a check will determine if the token is valid and matches the given
161+
project. If instead an authenticated user is used to make this request, a check
162+
will be performed to ensure the authenticated user is an owner of the project.
163+
164+
Payload validation
165+
------------------
166+
167+
If your project was imported through a connected account,
168+
we create a secret for every integration that offers a way to verify that a webhook request is legitimate.
169+
Currently, `GitHub <https://developer.github.com/webhooks/securing/>`__ and `GitLab <https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#validate-payloads-by-using-a-secret-token>`__
170+
offer a way to check this.
171+
172+
Troubleshooting
173+
---------------
174+
175+
Debugging webhooks
176+
^^^^^^^^^^^^^^^^^^
177+
178+
If you are experiencing problems with an existing webhook, you may be able to
179+
use the integration detail page to help debug the issue. Each project
180+
integration, such as a webhook or the generic API endpoint, stores the HTTP
181+
exchange that takes place between Read the Docs and the external source. You'll
182+
find a list of these exchanges in any of the integration detail pages.
183+
184+
185+
Webhook activation failed. Make sure you have the necessary permissions
186+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
187+
188+
If you find this error,
189+
make sure your user has permissions over the repository.
190+
In case of GitHub,
191+
check that you have granted access to the Read the Docs `OAuth App`_ to your organization.
192+
193+
.. _OAuth App: https://github.com/settings/applications
194+
195+
196+
My project isn't automatically building
197+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198+
199+
If your project isn't automatically building, you can check your integration on
200+
Read the Docs to see the payload sent to our servers. If there is no recent
201+
activity on your Read the Docs project webhook integration, then it's likely
202+
that your VCS provider is not configured correctly. If there is payload
203+
information on your Read the Docs project, you might need to verify that your
204+
versions are configured to build correctly.

docs/user/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ to help you create fantastic documentation for your project.
7878
/localization
7979
/choosing-a-site
8080
/build-notifications
81+
/integrations
8182
/custom-domains
8283
/pull-requests
8384
/downloadable-documentation
8485

85-
8686
.. toctree::
8787
:maxdepth: 2
8888
:hidden:
@@ -113,7 +113,6 @@ and some of the core features of Read the Docs.
113113

114114
* **Overview of core features**:
115115
:doc:`/features` |
116-
:doc:`/integrations` |
117116
:doc:`/custom-domains` |
118117
:doc:`/versions` |
119118
:doc:`/downloadable-documentation` |
@@ -179,6 +178,7 @@ and how to write successful documentation.
179178
:doc:`More guides for authors </guides/authors>`
180179

181180
* **For project administrators**:
181+
:doc:`Connect Your Git Repository </guides/git-integrations>` |
182182
:doc:`Manage Custom Domains </guides/custom-domains>` |
183183
:doc:`/guides/technical-docs-seo-guide` |
184184
:doc:`/guides/manage-translations-sphinx` |

0 commit comments

Comments
 (0)