Skip to content
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

Implement GitHub webhooks #69

Open
wants to merge 4 commits into
base: feature/use-sqlite-db
Choose a base branch
from

Conversation

danlivings-dxw
Copy link
Contributor

This PR allows Towtruck to listen for several types of events on the POST /api/github/webhooks endpoint. This can be used to incrementally update the database and spreading out the requests it makes to the GitHub API, rather than issuing a large number of requests in a short window of time as it does when seeding.

The events it listens for are:

  • pull_request.opened and pull_request.closed to update the list of open pull requests
  • issues.opened and issues.closed to update the list of open issues
  • push and issues.edited to update the list of dependencies
  • dependabot_alert to update the list of vulnerabilities
  • repository to update basic information about repositories

NB: this pull request depends on #63, which should be merged first.

This will allow webhooks to call this function to ensure that new
dependencies have lifetime information if it is available.
The logic used to fetch and store information about repositories and
dependencies will need to be reused to allow webhooks to make changes to
the database. Using the logic in the application rather than in one-off
seeding scripts makes it more important that it is tested to avoid
unexpected changes to behaviour. This moves the actual seed scripts to
wrapper scripts in the `seed` folder, which call the methods in the
original files that have been refactored to be more testable.
To update dependency or repository information in an efficient way,
Towtruck should listen to GitHub events rather than polling for updates.
Towtruck needs to listen to the following events:

- `pull_request.opened` and `pull_request.closed` to update the list of
  open pull requests
- `issues.opened` and `issues.closed` to update the list of open issues
- `push` and `issues.edited` to update the list of dependencies
- `dependabot_alert` to update the list of vulnerabilities
- `repository` to update basic information about repositories
@danlivings-dxw danlivings-dxw linked an issue Oct 10, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add webhooks
1 participant