feat(github): add GitHub App integration#19641
Conversation
|
I am working on more testing to ensure that adding the github integration doesn't break existing github pull request or other git integrations. |
|
Does it work for organization-scoped repos as well? (I will look in more detail later, I'm just curious) |
|
Yes it should but I have not had the opportunity to test it because of lack of organization access to install it in. |
| on_delete=models.SET_NULL, | ||
| null=True, | ||
| blank=True, | ||
| ) |
There was a problem hiding this comment.
I wonder whether scoping this to the user is the right approach. The user indeed has to initiate this, but shouldn't the connection be bound to a project? Or workspace once #19535 lands?
There was a problem hiding this comment.
Hmm, good point. I will rework this to project for now and yes workspace seems to make more sense once available.
| kwargs["existing_form"] = kwargs["form"] | ||
| installations = GitHubInstallation.objects.filter(enabled=True).order_by( | ||
| "target_login", "hostname" | ||
| ) |
There was a problem hiding this comment.
This should do some scope filtering, in this way, it exposes all site GitHub installations to all users.
|
This is Codex review of the changes:
|
|
Thinking more about this, I don't think the app should use the same webhook endpoint as generic GitHub hooks. The app hooks should always require signing and should do no fuzzy matching on the repositories, as the repository URL is configured via the app. |
|
Makes sense, will update. Have you been able to test this manually yet? I can deploy a version locally and expose it online for you to access and test if not. |
|
I will get to it soon. First, I want to land basic workspaces code to main. |
|
Just tried this:
|
|
|
2 is IMHO caused by not setting callback/setup URLs on GitHub. After selecting where to install the GitHub app, I ended up on https://github.com/settings/installations/135697804 rather than in Weblate where I would choose which repo to import. Yes, the basics of workspaces are now there, but I have several follow-up pull requests prepared so that it doesn't all land in one massive change (#19729 is the current next step). |
|
While working on the workspaces, I this we can make the GitHub app work only with workspaces and do not support project-scoped installs at all. This will simplify the code and the limitation should not be that constraining, it just needs to be documented. |
Implement GitHub App based authentication as an alternative to personal access tokens for GitHub-backed repositories. The integration stores the app configuration and installation metadata, exchanges app credentials for installation access tokens, and uses those tokens when Weblate performs GitHub repository operations.
Add one-click registration from Manage → Weblate GitHub Apps. The form POSTs a GitHub App manifest containing the required permissions, events, and webhook URL; GitHub returns the App ID, slug, private key, and webhook secret, which Weblate stores in a new GitHubAppCredentials table. Also, move the github app creation from project level to workspace level.
f10dfa3 to
7845c2a
Compare
|
|
The registration looks nice and makes it harder to mess up the setup. Storing the credentials in the database is IMHO okay. I'm still unsure about the hooks code, I don't think we should do that much of guessing there. How about exposing hook per integration (let's say Overall while this PR is GitHub specific, it should be prepared for a generalization later. For integration/webhooks, we would like to support other code sites such as GitLab or Forgejo. So the model should be prepared for that. Enabling authenticated webhooks (via the integration) should disable unauthenticated hooks on that component. For VCS integration:
This is not the scope we need to cover in this pull request, but the GitHub integration should go in the right direction. |

Implement GitHub App based authentication as an alternative to personal access tokens for GitHub-backed repositories. The integration stores the app configuration and installation metadata, exchanges app credentials for installation access tokens, and uses those tokens when Weblate performs GitHub repository operations.