You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-5Lines changed: 25 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,7 +107,7 @@ cog.outl(f"- Django {', '.join([version for version in DJ_VERSIONS if version !=
107
107
> - Use `"async"` with `AsyncWebhookView`
108
108
> - Use `"sync"` with `SyncWebhookView`
109
109
110
-
5. Setup your GitHub App, either by registering a new one or importing an existing one, and configure django-github-app using your GitHub App's information.
110
+
5. Setup your GitHub App and configure django-github-app using your GitHub App's information.
111
111
112
112
You will need the following information from your GitHub App:
113
113
@@ -136,7 +136,22 @@ cog.outl(f"- Django {', '.join([version for version in DJ_VERSIONS if version !=
136
136
>
137
137
> django-github-app will automatically detect if `GITHUB_APP["PRIVATE_KEY"]` is a path and load the file contents. For more information, see the [`PRIVATE_KEY`](#private_key) section in the [Configuration](#configuration) documentation below.
138
138
139
-
### Create a New GitHub App
139
+
### GitHub App Setup
140
+
141
+
After completing the [Installation](#installation) steps above, you will need to set up your GitHub App using the information from Step 5 above.
142
+
143
+
Choose the appropriate setup method based on your situation:
144
+
145
+
- **[Create a New GitHub App](#create-a-new-github-app)**: If you're setting up a fresh GitHub App
146
+
- **[Use an Existing GitHub App](#use-an-existing-github-app-and-installation)**: If your GitHub App is already installed on organizations/repositories
147
+
148
+
> [!IMPORTANT]
149
+
> django-github-app needs to create `Installation` and `Repository` models in your database to track where your GitHub App is installed. How this happens depends on your setup method:
150
+
>
151
+
> - **New GitHub App**: When you install the app for the first time, GitHub sends an `installation.created` webhook event. django-github-app automatically creates the necessary models when it receives this event.
152
+
> - **Existing GitHub App**: If the app is already installed, no `installation.created` webhook event is sent. You must use the `github import-app` management command to manually create the models.
153
+
154
+
#### Create a New GitHub App
140
155
141
156
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).
142
157
@@ -169,9 +184,11 @@ cog.outl(f"- Django {', '.join([version for version in DJ_VERSIONS if version !=
169
184
- Select the account to install it on
170
185
- Choose which repositories to give it access to
171
186
172
-
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.
187
+
When you install the app **for the first time**, django-github-app will automatically create the necessary `Installation` and `Repository` models when it receives the `installation.created` webhook event.
188
+
189
+
#### Use an Existing GitHub App and Installation
173
190
174
-
### Use an Existing GitHub App and Installation
191
+
If your GitHub App is already installed on organization/repositories, the `installation.created` webhook event won't be sent when you connect django-github-app to your existing app. In this case, you need to manually import the installation data.
175
192
176
193
1. Collect your existing app and installation's information.
177
194
@@ -199,7 +216,7 @@ cog.outl(f"- Django {', '.join([version for version in DJ_VERSIONS if version !=
199
216
}
200
217
```
201
218
202
-
3. Import your existing GitHub App by using the `github import-app` management command.
219
+
3. Import your existing GitHub App by using the `github import-app` management command to create the necessary `Installation` and `Repository` models.
203
220
204
221
```bash
205
222
python manage.py github import-app --type user --name <username> --installation-id 123456
@@ -209,6 +226,9 @@ cog.outl(f"- Django {', '.join([version for version in DJ_VERSIONS if version !=
209
226
uv run manage.py github import-app --type user --name <username> --installation-id 123456
210
227
```
211
228
229
+
> [!NOTE]
230
+
> After importing, django-github-app will handle future webhook events normally, including repository additions/removals via the `installation_repositories` event.
0 commit comments