Go to file
2023-12-20 02:05:36 +01:00
LICENSE feat: initial commit 2023-12-20 02:05:36 +01:00
README.md feat: initial commit 2023-12-20 02:05:36 +01:00
semaphore-webhook-server.py feat: initial commit 2023-12-20 02:05:36 +01:00

Semaphore Webhook Server

A small Python webservice to extend the API of Semaphore UI with a "webhook" enpoint to start tasks.

Installation

  1. Put the script onto your Semaphore server.
  2. Run it e.g. as a systemd service.
  3. Configure the reverse proxy to proxy a path of your choice to http://localhost:3042/webhook rather than Semaphore.
    • Apache example:

        ProxyPass /.well-known !
        # Webhook server - must be before semaphre
        ProxyPass /webhook http://localhost:3042/webhook
        ProxyPassReverse /webhook http://localhost:3042/webhook
        # Semaphore
        ProxyPass /api/ws ws://localhost:3000/api/ws
        ProxyPass / http://localhost:3000/
        ProxyPassReverse / http://localhost:3000/
      

Usage

The easiest to use this webhook endpoint, simply GET or POST the /webhook endpoint with the project_id and template_id parameters:

GET /webhook?project_id=1&template_id=1 HTTP/1.1
Host: semaphore.example.org
Authorization: Bearer ...

These two parameters are required. The total set of supporter parameters are:

  • project_id (required): int
  • template_id (required): int
  • debug: bool, true or false
  • dry_run: bool
  • diff: bool

Each request to the webhook server is transformed into a request to the Semaphore API's POST /project/{project_id}/tasks endpoint.

The authorization header is passed on to Semaphore unmodified.