https://github.com/bholmesdev/prismic-webhooks
DYI webhooks demo project
https://github.com/bholmesdev/prismic-webhooks
blog
Last synced: 11 months ago
JSON representation
DYI webhooks demo project
- Host: GitHub
- URL: https://github.com/bholmesdev/prismic-webhooks
- Owner: bholmesdev
- Created: 2023-08-24T01:48:57.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-24T03:38:34.000Z (over 2 years ago)
- Last Synced: 2025-02-10T03:16:42.592Z (about 1 year ago)
- Topics: blog
- Language: TypeScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Webhook demo - CMiniS
This is a simple demo of webhooks with a dummy CMS and a dummy static site builder. Built on [Deno](https://deno.com/) and deployable to [Railway](https://railway.app).
## Architecture
You will find 2 separate servers in this repo:
- `cms/` - A CMS server that lets you edit a post and configure webhooks to call on each update
- `www/` - A www server with a `/build-hook` URL to triggers a build
## Get started
1. Install [Deno](https://deno.land/manual@v1.36.2/getting_started/installation) on your machine.
2. Seed the CMS' SQLite database by running `deno task cms:seed`.
3. Start the `www` and `cms` servers by running `deno task dev`.
5. Visit the CMS at http://localhost:3000. This will have a sample title and body displayed from our SQLite database.
### Test your webhook
1. Visit the example site at http://localhost:5000. You should see a placeholder message noting the site isn't built yet. Let's change that!
2. Head back to the CMS server at http://localhost/3000, and configure a webhook by submitting http://localhost:5000/build-hook under the Webhooks form.
3. Edit the post contents and hit "Update." Heading back to http://localhost:5000, you should see your built site 🥳 There should also be a generated `www/built.html` file in your project directory.
## Deploy the Railway
This repo is configured to deploy to [Railway](https://railway.app).
1. Publish your clone of this repository to a personal GitHub account. This is because Railway relies on GitHub repositories for live redeployments.
2. Create a new Railway account with your GitHub credentials
3. Create a new project from your new GitHub repository.
4. Under "Settings," update the `build` and `start` commands for the server you would like to deploy. This example configured the CMS service for deployment:

5. Under "Settings > Environment," create a custom domain with the Add button. This should expose your CMS service on a public URL:

6. To deploy the `www` application, you'll need to create a _second_ new project using the same GitHub repository, and replace the above deploy command with `deno task www:serve`.
7. With each of these deployed, you can follow the "Test your webhook" instructions above using the public Railway domain as your webhook.