Webhooks

Rebuild on publish

Start a new build of a prerendered site when an editor publishes.

A prerendered site shows content from its last build. A webhook to the deploy hook of your host starts a new build after each change:

tenon.config.ts
webhooks: {
  rebuild: { url: process.env.DEPLOY_HOOK_URL!, debounce: 60 },
},

Add a deploy button

Some teams publish several changes, then deploy once. An action adds a Deploy button to the admin. The hook URL stays on the server:

tenon.config.ts
admin: {
  actions: {
    deploy: {
      label: "Deploy",
      nav: { icon: "rocket" },
      confirm: "Rebuild and publish the live site?",
      run: async () => {
        const response = await fetch(process.env.DEPLOY_HOOK_URL!, { method: "POST" });
        if (!response.ok) throw new Error(`The deploy hook answered ${response.status}`);
        return "Deploy started";
      },
    },
  },
},

The action calls the hook at once. It does not wait for the clock.