Skip to content

Conversation

@filiptronicek
Copy link
Member

Description

Improves the way we detect if you have webhooks installed on a specific repo. The approach with this PR changes to the following:

  1. We check the host if it knows about a webhook for the current Gitpod host. If we lack permissions, we continue to step 2, otherwise, we return the result of this check.
  2. (GitHub-specific) we look at the pushedAt date to determine when we should've received the last push event and see if we have received some webhook event after that date. If so, we return it.
  3. We query the latest webhook events we got for the repo. We go through them one-by-one and if one of the events matches the latest commit SHA of the repo's default branch, we return that event.

Related Issues

Contributes to ENT-601 as a follow-up for #20228

How to test

https://ft-super-d2d2fa388b8.preview.gitpod-dev.com/repositories

  1. Import a repository
  2. Enable prebuilds on it (should install webhook)
  3. The prebuild settings page should say that the trigger strategy is "Webhook-based"
  4. Remove the webhook on the Git host
  5. Create a workspace for that repository, wait for it to create
  6. Check its prebuild settings again, it should now say "Activity-based" in the trigger strategy section.

/hold

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, tested and works! ✔️

(I had to do a hard reload on the repo config page, but I think that's fine)

@roboquat roboquat merged commit d1e314b into main Sep 25, 2024
19 checks passed
@roboquat roboquat deleted the ft/super-duper-webhook-detection branch September 25, 2024 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants