Skip to content

Commit f8bffe5

Browse files
adjust formatting
1 parent 06a81fe commit f8bffe5

File tree

2 files changed

+98
-91
lines changed

2 files changed

+98
-91
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,14 @@ Windows users will need to adjust commands accordingly, though the core workflow
7373
Alternatively, any Python package manager that supports installing from `pyproject.toml` ([PEP 621](https://peps.python.org/pep-0621/)) can be used. If not using `uv`, ensure you have Python installed from [python.org](https://www.python.org/).
7474

7575
1. Fork the repository and clone it locally.
76+
7677
2. Use `uv` too bootstrap your development environment:
7778

78-
```bash
79-
uv python install
80-
uv sync --locked
81-
# just bootstrap
82-
```
79+
```bash
80+
uv python install
81+
uv sync --locked
82+
# just bootstrap
83+
```
8384

8485
This will install the correct Python version, create and configure a virtual environment, and install all dependencies.
8586

@@ -140,14 +141,17 @@ uv run nox --session test -- --integration
140141
#### Setting up a Test GitHub App
141142

142143
1. Create a new GitHub App.
144+
143145
- Go to GitHub Developer Settings > GitHub Apps > New GitHub App
144146
- Name: `@<username> - django-github-app tests` (must be unique on GitHub, max 34 characters)
145147
- Homepage URL: Your fork's URL (e.g., `https://github.com/<username>/django-github-app`)
146148
- Webhooks: Disable by unchecking "Active" (no webhook tests currently implemented)
147149
- Permissions:
148150
- Repository: Metadata (Read-only)
149151
- Installation: "Only on this account"
152+
150153
2. After creation, collect these values:
154+
151155
- App ID (from app settings)
152156
- Client ID (from app settings)
153157
- Private key (generate and download)
@@ -177,8 +181,11 @@ See [`.env.example`](.env.example) for all required variables and their descript
177181
If you want integration tests to run in CI on your fork:
178182

179183
1. Go to your fork's repository settings on GitHub
184+
180185
2. Under "Environments", create a new environment named `integration`
186+
181187
3. Add the following secrets and variables to the environment:
188+
182189
- Secrets
183190
- `TEST_PRIVATE_KEY`
184191
- `TEST_WEBHOOK_SECRET`

README.md

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -76,92 +76,92 @@ The library is async-only at the moment (following gidgethub), with sync support
7676
7777
All examples below use [environs](https://github.com/sloria/environs) to load the values from an `.env` file. Adjust the code to your preferred way of loading Django settings.
7878
79-
> [!NOTE]
80-
> By default, examples use the private key contents loaded directly from environment. To use a key file instead:
81-
>
82-
> ```python
83-
> import environs
84-
>
85-
> env = environs.Env()
86-
> env.read_env()
87-
>
88-
> GITHUB_APP = {
89-
> "PRIVATE_KEY": env.path("GITHUB_PRIVATE_KEY_PATH"),
90-
> }
91-
> ```
92-
>
93-
> django-github-app will automatically detect if `GITHUB_APP["PRIVATE_KEY"]` is a path and load the file contents.
94-
95-
- **Option A: Create a new Github App**
96-
97-
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).
98-
99-
For the Private Key, you will be able to use either the file contents or the file itself to authenticate with GitHub, as described in the note above.
100-
101-
For the Webhook URL, use the endpoint you configured in step 4 (e.g., `<your project's base url>/gh/`).
102-
103-
2. Configure your Django settings by adding the following dictionary to your `DJANGO_SETTINGS_MODULE`, filling in the values from the previous setup.
104-
105-
```python
106-
import environs
107-
108-
env = environs.Env()
109-
env.read_env()
110-
111-
GITHUB_APP = {
112-
"APP_ID": env.int("GITHUB_APP_ID"),
113-
"CLIENT_ID": env.str("GITHUB_CLIENT_ID"),
114-
"NAME": env.str("GITHUB_NAME"),
115-
"PRIVATE_KEY": env.str("GITHUB_PRIVATE_KEY"),
116-
"WEBHOOK_SECRET": env.str("GITHUB_WEBHOOK_SECRET"),
117-
}
118-
```
119-
120-
3. Install the GitHub App on your account:
121-
122-
- Go to your GitHub App's settings
123-
- Click "Install App"
124-
- Select the account to install it on
125-
- Choose which repositories to give it access to
126-
127-
When you install the app, django-github-app will automatically create the necessary `Installation` and `Repository` models when it receives the `installation.created` webhook event.
128-
129-
- **Option B: Use an existing GitHub App and Installation**
130-
131-
1. Collect your existing app and installation's information:
132-
133-
- All GitHub App information and credentials listed above
134-
- Make sure the Webhook URL matches the endpoint configured in step 4
135-
- Account type where installed (`org` or `user`)
136-
- Account name (username or organization name)
137-
- Installation ID (e.g. `https://github.com/settings/installations/<ID>` for an user installation)
138-
139-
2. Configure your Django settings by adding the following dictionary to your `DJANGO_SETTINGS_MODULE`, filling in the values from your existing GitHub App.
140-
141-
```python
142-
import environs
143-
144-
env = environs.Env()
145-
env.read_env()
146-
147-
GITHUB_APP = {
148-
"APP_ID": env.int("GITHUB_APP_ID"),
149-
"CLIENT_ID": env.str("GITHUB_CLIENT_ID"),
150-
"NAME": env.str("GITHUB_NAME"),
151-
"PRIVATE_KEY": env.str("GITHUB_PRIVATE_KEY"),
152-
"WEBHOOK_SECRET": env.str("GITHUB_WEBHOOK_SECRET"),
153-
}
154-
```
155-
156-
3. Import your existing GitHub App by using the provided management command:
157-
158-
```bash
159-
python manage.py github import-app --type user --name <username> --installation-id 123456
160-
161-
# or for you thrill seekers and early adopters
162-
163-
uv run manage.py github import-app --type user --name <username> --installation-id 123456
164-
```
79+
> [!NOTE]
80+
> By default, examples use the private key contents loaded directly from environment. To use a key file instead:
81+
>
82+
> ```python
83+
> import environs
84+
>
85+
> env = environs.Env()
86+
> env.read_env()
87+
>
88+
> GITHUB_APP = {
89+
> "PRIVATE_KEY": env.path("GITHUB_PRIVATE_KEY_PATH"),
90+
> }
91+
> ```
92+
>
93+
> django-github-app will automatically detect if `GITHUB_APP["PRIVATE_KEY"]` is a path and load the file contents.
94+
95+
**Option A: Create a new Github App**
96+
97+
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).
98+
99+
For the Private Key, you will be able to use either the file contents or the file itself to authenticate with GitHub, as described in the note above.
100+
101+
For the Webhook URL, use the endpoint you configured in step 4 (e.g., `<your project's base url>/gh/`).
102+
103+
2. Configure your Django settings by adding the following dictionary to your `DJANGO_SETTINGS_MODULE`, filling in the values from the previous setup.
104+
105+
```python
106+
import environs
107+
108+
env = environs.Env()
109+
env.read_env()
110+
111+
GITHUB_APP = {
112+
"APP_ID": env.int("GITHUB_APP_ID"),
113+
"CLIENT_ID": env.str("GITHUB_CLIENT_ID"),
114+
"NAME": env.str("GITHUB_NAME"),
115+
"PRIVATE_KEY": env.str("GITHUB_PRIVATE_KEY"),
116+
"WEBHOOK_SECRET": env.str("GITHUB_WEBHOOK_SECRET"),
117+
}
118+
```
119+
120+
3. Install the GitHub App on your account:
121+
122+
- Go to your GitHub App's settings
123+
- Click "Install App"
124+
- Select the account to install it on
125+
- Choose which repositories to give it access to
126+
127+
When you install the app, django-github-app will automatically create the necessary `Installation` and `Repository` models when it receives the `installation.created` webhook event.
128+
129+
**Option B: Use an existing GitHub App and Installation**
130+
131+
1. Collect your existing app and installation's information:
132+
133+
- All GitHub App information and credentials listed above
134+
- Make sure the Webhook URL matches the endpoint configured in step 4
135+
- Account type where installed (`org` or `user`)
136+
- Account name (username or organization name)
137+
- Installation ID (e.g. `https://github.com/settings/installations/<ID>` for an user installation)
138+
139+
2. Configure your Django settings by adding the following dictionary to your `DJANGO_SETTINGS_MODULE`, filling in the values from your existing GitHub App.
140+
141+
```python
142+
import environs
143+
144+
env = environs.Env()
145+
env.read_env()
146+
147+
GITHUB_APP = {
148+
"APP_ID": env.int("GITHUB_APP_ID"),
149+
"CLIENT_ID": env.str("GITHUB_CLIENT_ID"),
150+
"NAME": env.str("GITHUB_NAME"),
151+
"PRIVATE_KEY": env.str("GITHUB_PRIVATE_KEY"),
152+
"WEBHOOK_SECRET": env.str("GITHUB_WEBHOOK_SECRET"),
153+
}
154+
```
155+
156+
3. Import your existing GitHub App by using the provided management command:
157+
158+
```bash
159+
python manage.py github import-app --type user --name <username> --installation-id 123456
160+
161+
# or for you thrill seekers and early adopters
162+
163+
uv run manage.py github import-app --type user --name <username> --installation-id 123456
164+
```
165165
166166
## Getting Started
167167

0 commit comments

Comments
 (0)