Skip to content

Implement WEBHOOK_PUSH/PULL_REQUEST jobs #206

Description

@fennifith

When a push or pull request payload is received, we need to determine the diff from the last sync, or from the current main branch.

This can be done with the /repos/{owner}/{repo}/compare/{basehead} API: https://docs.github.com/en/rest/commits/commits?apiVersion=2026-03-10#compare-two-commits

For push payloads...

Verify that the branch is main (if not, log & return). Use the before and after sha properties as the base/head of the comparison.

For pull_request payloads...

We will need a new table to record previous pull_request imports. This should track the branch name (indexed & unique) and the commit sha, with a uuid PK.

When a new event is received, find the last processed commit sha from the database, and use that as the base for the comparison. Otherwise, use the base.sha from the pull request payload.

After fetching the comparison (in both jobs):

Iterate through files[] and collect file paths that match any post, collection, or author contents. (note that posts and post subdirs are both counted, whereas authors/collections only count files directly within their folders)

  • content/{user}/* -> author
  • content/{user}/posts/{post}/** -> post
  • content/{user}/collections/{collection}/* -> collection
  • content/{user}/collections/{collection}/posts/{post}/** -> post

Then, for each discovered ID, trigger and await the response of the sync-author, sync-collection, and sync-post jobs.

These jobs can be parallelized, but the logic must consider dependencies - if both a collection and a post within the collection need to be synced, the collection must finish syncing before the post. Likewise for authors -> collections, or authors -> posts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions