ubiquity-os / ubiquity-os-kernel

1 stars 13 forks source link

Deploy To Cloudflare Workers #14

Closed 0x4007 closed 7 months ago

0x4007 commented 9 months ago

A core contributor of the @octokit/rest library (what Probot uses under the hood) AND Probot core contributor, has a tutorial for how to make Probot work on Cloudflare workers. I imagine this is pretty straightforward to implement.

https://dev.to/opensauced/deploy-a-github-application-to-cloudflare-workers-2gpm

I never liked Netlify and I think it makes a lot more sense to invest in the Cloudflare ecosystem

https://www.perplexity.ai/search/cloudflare-workers-probot-RuW4_UH9RgOi6o1n.oRXcw?s=c

Appendix

0x4007 commented 9 months ago

@whilefoo please prioritize this. I want to get off of Netlify ASAP.

whilefoo commented 9 months ago

https://dev.to/opensauced/deploy-a-github-application-to-cloudflare-workers-2gpm

This tutorial doesn't show how to use Probot on Cloudflare workers, instead they stopped using Probot and used github-app-webhook-relay

Core contributor said it's not compatible: https://github.com/probot/probot/issues/1656

0x4007 commented 9 months ago

Aside from the webhook relay I don't think we need Probot.

0x4007 commented 9 months ago

@whilefoo I started some research and have an MVP of a bot without Probot able to listen to webhook events here.

In essence it only uses @octokit/webhooks and smee-client (to relay the webhooks to your local machine.)

The next step is just to get it deployed on Cloudflare Workers which I have basically no experience of doing at the moment. Currently stuck on trying to deploy using wrangler cli, but I'm having permissions errors with my API key. Also I understand that Cloudflare Workers do NOT have a Node.js runtime so there are some special accommodations that need to be made, like http fetches and loading environment variables (I suspect that we need to use less popular npm libraries.) Fortunately I expect these accommodations to only be limited to a few I/O related matters. Most of the logic is internal.

If you're keen on helping me with my research let me know. I'm slowly hacking away at it there.

My vision is to dramatically simplify the bot architecture by just having separate files that correspond with the webhook event names i.e. handlers/issue_comment.created.ts. I extracted every webhook type here and apply it to the webhook listener in that code.

Lastly I think it could be interesting to do some research around adding support for custom event types, like handlers/telegram_message.created.ts so that the bot can expand its reach beyond GitHub.

I think we can work on this as a separate r&d effort while bringing the original UbiquiBot (with Probot) codebase to market in 2024.)

whilefoo commented 9 months ago

Sure, so you want to make a POC first and then we branch off the current bot and make the modifications?

0x4007 commented 9 months ago

Something like that yes.

ubiquibot[bot] commented 7 months ago
# Issue was not closed as completed. Skipping.
0x4007 commented 7 months ago

Given that we are already developing using miniflare, it implicitly will be able to be deployed to Cloudflare Workers.