Sign inSign up

timoreymann/mealie-webhook-handler

By timoreymann

•Updated 24 days ago

Webhook handler for recipes hosted on a mealie.io instance

Image
0

10K+

timoreymann/mealie-webhook-handler repository overview

⁠mealie-webhook-handler

GitHub Release Docker Pulls GitHub all releases download count LICENSE CircleCI Renovate codecov Quality Gate Status Maintainability Rating Security Rating


Webhook handler for recipes hosted on a mealie.io instance

⁠Features

  • Customizable templates
  • Generic output support

⁠Purpose

This small service bridges Mealie⁠ (self-hosted recipe manager) with external systems by:

  1. Listening for webhooks triggered by the user in the UI.
  2. Rendering recipes using customizable Go templates (e.g., for Chowdown⁠).
  3. Pushing output to destinations like GitHub repos (via PR)

Key Use Case: Automate syncing Mealie recipes to a Chowdown-compatible GitHub repo (or other targets) with minimal manual effort.

⁠Want to contribute a new output?

Right now the only supported output is GitHub via PR. If you have any other destinations feel free to either create an issue or contribute directly:

  1. Fork this repository
  2. Add a new output in outputs/<your name>/main.go (see github_pr for reference)
  3. Create a PR

⁠Installation

It's recommended to install it next to your mealie instance using docker-compose.

  1. Create webhook-templates/chowdown-template.gotpl

    ---
    layout: recipe
    title: {{ .Recipe.Name }}
    {{- if .HasImage }}
    image: {{ .Recipe.Slug }}.webp
    {{- end }}
    tags: {{- range $index, $tag := .Recipe.Tags }} {{- if $index }},{{ end }} {{ $tag.Name }} {{- end }}
    
    ingredients:
    {{- range $val := .Recipe.RecipeIngredient }}
      - {{ if $val.Quantity }} {{ $val.Quantity }}{{- end -}}{{- if $val.Unit }} {{ or $val.Unit.Abbreviation $val.Unit.Name }}{{- end }} {{ if or $val.Quantity $val.Unit }} {{- end }}{{ $val.Food.Name }}{{- if $val.Note }} {{ $val.Note }}{{- end }}
    {{- end }}
    
    directions:
    {{- range $val := .Recipe.RecipeInstructions }}
      - {{ $val.Text }}
    {{- end }}
    ---
    
    {{ .Recipe.Description }}
    
  2. Create a webhook-config.toml

    # chowdown is a sample GitHub webhook to sync recipes to chowdown github repos
    [webhook.chowdown_github_sync]
    template_path = "/etc/mealie-webhook-handler/templates/chowdown-template.gotpl"
    output = "github_pr"
     
    [webhook.chowdown_github_sync.output_options]
    title = "chore: Sync recipe {{ .Recipe.Name }} from mealie"
    body = """
    Update recipe {{ .Recipe.Name }}
    """
    slug = "your-user/recipes"
    source_branch = "sync/recipe/{{ .Recipe.Slug }}"
    target_branch = "gh-pages"
    recipe_path = "_recipes/{{ .Recipe.Slug }}.md"
    image_path = "images/{{ .Recipe.Slug }}.webp"
    commit_message = "chore: Sync {{ .Recipe.Name }} from mealie"
     
    [mealie]
    api_url = "http://mealie:9000/api"
    
  3. Configure the webhook handler next to mealie

    services:
      mealie:
        # Mealie 3.26.0+ requires the internal handler hostname to be allowed
        # for Recipe Actions.
        image: ghcr.io/mealie-recipes/mealie:latest
        environment:
          HTTP_ALLOW_LIST: mealie-webhook-handler
      mealie-webhook-handler:
        image: timoreymann/mealie-webhook-handler
        restart: always
        environment:
          GITHUB_TOKEN: <personal access token>
        command:
          - mealie-webhook-handler
          - --config-file
          - /etc/mealie-webhook-handler/config.toml
        volumes:
          - ./webhook-config.toml:/etc/mealie-webhook-handler/config.toml
          - ./webhook-templates:/etc/mealie-webhook-handler/templates
    

    For Mealie 3.26.0 and newer, add the webhook handler's exact Docker DNS hostname to Mealie's HTTP_ALLOW_LIST. The hostname must match the host used in the Recipe Action URL, for example http://mealie-webhook-handler:2025/webhook/chowdown_github_sync. If your service has a different name, use that name instead. Multiple allowed hosts can be provided as a comma-separated list. See Mealie's HTTP allow-list security configuration⁠.

⁠Usage

  1. Navigate to your Mealie instance
  2. Go to Settings > Data Management
  3. Select Recipe Actions
  4. Click Create
  5. Fill out the form
  6. On your recipe page open the actions and click on Sync to Chowdown
  7. A PR will be created in your chowdown repo
⁠Creating the template

Creating templates can sometimes be tricky, to make it easier there is the playground⁠ that can be used.

Simply put your template in, pick one of the predefined webhook payloads or paste a custom one and get immediate feedback.

⁠Motivation

⁠Contributing

I love your input! I want to make contributing to this project as easy and transparent as possible, whether it's:

  • Reporting a bug
  • Discussing the current state of the configuration
  • Submitting a fix
  • Proposing new features
  • Becoming a maintainer

To get started please read the Contribution Guidelines⁠.

⁠Development

⁠Requirements
⁠Test
make test-coverage-report
⁠Build
make build

Tag summary

Content type

Image

Digest

sha256:883d9e73a…

Size

8 MB

Last updated

24 days ago

docker pull timoreymann/mealie-webhook-handler