Skip to content

Commit d9043a3

Browse files
update installation instructions
1 parent 6c1db18 commit d9043a3

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,17 @@
1717

1818
## Installation
1919

20-
1. Install the package from PyPI:
20+
1. Register a new GitHub App, following [these instructions](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) from the GitHub Docs. For a more detailed tutorial, there is also [this page](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/building-a-github-app-that-responds-to-webhook-events) -- in particular the section on [Setup](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/building-a-github-app-that-responds-to-webhook-events#setup).
21+
22+
Make note of the following information while setting up your new GitHub App:
23+
24+
- App ID
25+
- Client ID
26+
- Name
27+
- Private Key (either the file object itself or the actual text)
28+
- Webhook Secret
29+
30+
2. Install the package from PyPI:
2131

2232
```bash
2333
python -m pip install django-github-app
@@ -28,7 +38,7 @@
2838
uv sync
2939
```
3040

31-
2. Add the app to your Django project's `INSTALLED_APPS`:
41+
3. Add the app to your Django project's `INSTALLED_APPS`:
3242
3343
```python
3444
INSTALLED_APPS = [
@@ -38,6 +48,36 @@
3848
]
3949
```
4050
51+
4. Add the following dictionary to your Django project's `DJANGO_SETTINGS_MODULE`, filling in the values from step 1 above. The example below uses [environs](https://github.com/sloria/environs) to load the values from an `.env` file.
52+
53+
```python
54+
import environs
55+
56+
env = environs.Env()
57+
env.read_env()
58+
59+
GITHUB_APP = {
60+
"APP_ID": env.int("GITHUB_APP_ID"),
61+
"CLIENT_ID": env.str("GITHUB_CLIENT_ID"),
62+
"NAME": env.str("GITHUB_NAME"),
63+
"PRIVATE_KEY": env.str("GITHUB_PRIVATE_KEY"),
64+
"WEBHOOK_SECRET": env.str("GITHUB_WEBHOOK_SECRET"),
65+
}
66+
```
67+
68+
> [!NOTE]
69+
> In this example, the private key's contents are set and loaded directly from the environment. If you prefer to use the file itself, you could do something like this instead:
70+
>
71+
> ```python
72+
> from pathlib import Path
73+
>
74+
> GITHUB_APP = {
75+
> ...
76+
> "PRIVATE_KEY": Path(env.path("GITHUB_PRIVATE_KEY_PATH")).read_text(),
77+
> ...
78+
> }
79+
> ```
80+
4181
## Getting Started
4282
4383
## Documentation

0 commit comments

Comments
 (0)