-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Docs: environment variables #8390
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Environment Variables | ||
===================== | ||
|
||
It may happen that your documentation depends on an authenticated service to be built properly. | ||
In this case, you will require some secrets to access these services. | ||
|
||
Read the Docs provides a way to define environment variables for your project to be used in the build process. | ||
They will be exposed to all the commands executed when building your documentation. | ||
|
||
To define an environment variable, you need to | ||
|
||
#. Go to your project's :guilabel:`Admin` > :guilabel:`Environment Variables` | ||
#. Click on :guilabel:`Add Environment Variable` | ||
#. Fill the ``Name`` and ``Value`` (your secret) | ||
#. Check the :guilabel:`Public` option if you want to expose this environment variable | ||
to :doc:`builds from pull requests </pull-requests>`. | ||
#. Click on :guilabel:`Save` | ||
|
||
.. note:: | ||
|
||
Once you create an environment variable, | ||
you won't be able to see its value anymore. | ||
|
||
After adding an environment variable, | ||
you can read it from your build process, | ||
for example in your Sphinx's ``conf.py`` file: | ||
|
||
.. code-block:: python | ||
|
||
# conf.py | ||
import os | ||
import requests | ||
|
||
# Access to our custom environment variables | ||
username = os.environ.get('USERNAME') | ||
password = os.environ.get('PASSWORD') | ||
|
||
# Request a username/password protected URL | ||
response = requests.get( | ||
'https://httpbin.org/basic-auth/username/password', | ||
auth=(username, password), | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.