8000 GitHub - hungdoansy/mitten: Self-hosted Slack bot that syncs GitHub pull requests and GitLab merge requests into Slack threads: paste a link, and every push, review, comment, merge and close posts under it. · GitHub
[go: up one dir, main page]

Skip to content
hungdoansyPublic

About

Self-hosted Slack bot that syncs GitHub pull requests and GitLab merge requests into Slack threads: paste a link, and every push, review, comment, merge and close posts under it.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

54 Commits

Folders and files

Repository files navigation

mitten

mitten

mitten is a Slack bot that keeps code review in Slack. Post a GitHub pull request or GitLab merge request link in a channel, and every push, review, comment, merge and close is posted as a reply in that message's thread. The discussion stays where the review was asked for, and the original message gets a badge when the PR merges or closes. One deployment serves GitHub and GitLab together, including GitHub Enterprise Server and self-managed GitLab.

How it works

  • GitHub and GitLab send webhooks to mitten, which checks each one's signature and queues it.
  • A worker turns each delivery into events (pushed, reviewed, commented, merged, closed, reopened) and finds every Slack thread tracking that PR.
  • Each thread gets one post, rate-limited per channel. A delivered marker in Redis stops a redelivered webhook from posting twice.

The full picture, with diagrams: docs/architecture.html.

mitten reads PRs with its own GitHub App or GitLab token, so a tracked private PR is visible to everyone in the channel. By default full members can track, guests and people from other organizations cannot, and channels shared with other organizations start off. The optional admin console changes those defaults, or switches one channel or person. See who sees what.

Quickstart

New to mitten? Follow the setup guide (also in Markdown: docs/setup.md): every step from nothing to a running bot on your own machine with ngrok, including where each .env value comes from. The admin console is optional and comes last. The short version, for a server:

You need Docker, a host Slack and your git host can reach over HTTPS, and admin rights on the Slack workspace and on the GitHub organization or GitLab group.

  1. Create the Slack app from slack-app-manifest.yml and install it: docs/slack-app-setup.md.

  2. Set up GitHub, GitLab, or both: docs/github-app-setup.md, docs/gitlab-setup.md.

  3. Configure mitten:

    cp .env.example .env

    Fill in Slack and BASE_URL, and uncomment and fill in your provider(s); the table below lists every variable the bot needs; the console's are under admin console.

  4. Start mitten, Postgres and Redis. Migrations run first, on their own:

    docker compose up -d

    To build the image from this checkout instead of pulling it, uncomment the build: blocks in docker-compose.yml and run docker compose up -d --build. Put it behind a TLS proxy: docs/deployment.md.

  5. Try it: /invite @mitten in a channel, then post "please review" with a PR link.

Environment variables

.env.example lists the same variables, grouped, with comments. A provider is on when its whole group is set and off when none of it is. A partly set group, or no provider at all, stops boot with a message naming what is missing. Every other variable is checked against a schema at boot (apps/bot/src/config/env.ts), and one error names every missing or malformed value.

Variable Required Default Purpose
SLACK_BOT_TOKEN yes The bot token, xoxb-…: Slack app → OAuth & Permissions → Bot User OAuth Token
SLACK_SIGNING_SECRET yes Verifies requests from Slack: Basic Information → Signing Secret
GITHUB_APP_ID GitHub group The App ID, a number at the top of the GitHub App's settings page
GITHUB_PRIVATE_KEY GitHub group The App's private key: Private keys → Generate a private key, the downloaded .pem's contents
GITHUB_WEBHOOK_SECRET GitHub group Verifies GitHub webhooks: a random string you choose, set as the App's webhook secret too
GITHUB_BASE_URL no https://github.com A GitHub Enterprise Server root; the API is then <root>/api/v3
GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET both or neither Turn on GitHub account linking; need the GitHub group and ENCRYPTION_KEY. The App's Client ID (Iv…, not the App ID) and a secret from Client secrets → Generate
GITLAB_TOKEN GitLab group An access token with read_api
GITLAB_WEBHOOK_SECRET GitLab group Verifies GitLab webhooks (the secret token)
GITLAB_BASE_URL no https://gitlab.com A self-managed GitLab root; the API is <root>/api/v4
GITLAB_CLIENT_ID, GITLAB_CLIENT_SECRET both or neither Turn on GitLab account linking; need the GitLab group and ENCRYPTION_KEY
ENCRYPTION_KEY with linking Encrypts linked accounts' tokens: openssl rand -hex 32 (at least 32 characters; boot refuses a shorter one). Changing it means everyone links again
POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB yes Postgres credentials; compose builds the database from them
DATABASE_URL yes Postgres URL for the bot and the db:* scripts on your machine; compose sets its own in-network one
REDIS_URL yes redis:// or rediss://; compose sets its own in-network one
BASE_URL no http://localhost:7060 mitten's public http(s):// URL, no trailing slash; builds the linking callback URLs, so it must match the callback registered with each host
PORT no 7060 The HTTP port, 1–65535
NODE_ENV no development production logs JSON; the image and compose set it
APP_ENV no development The deployment tier (development, staging, production) reported in logs
CONSOLE_URL no The admin console's public URL, so the approval DMs mitten sends admins link to the page that acts on them
LOG_LEVEL no info Winston log level: error, warn, info, http, verbose, debug or silly; debug also logs each Prisma query

Where each GitHub value is on the App's page, and setup gotchas: GitHub setup notes.

Queue concurrency, retries and rate-limit spacing are constants in apps/bot/src/config/index.ts, not env vars.

The optional admin console adds SLACK_CLIENT_ID, SLACK_CLIENT_SECRET, CONSOLE_SESSION_SECRET, SLACK_TEAM_ID and BOT_URL, plus CONSOLE_API_SECRET and CONSOLE_ADMIN_EMAILS, which the bot reads too, and an optional CONSOLE_URL on the bot for the links in its approval DMs.

Commands

Track a PR by posting its link with the word "review", reacting :mitten: to a message with a link, or the Track PRs message shortcut. The full guide: docs/pr-tracking.md.

Commands work as /mitten <command> or @mitten <command>, and reply only to you:

Command Does
help Lists the commands
status Whether mitten is in this channel, PRs tracked here, providers on, your account links
untrack As @mitten untrack inside a tracked thread: stops tracking its PRs
link github / link gitlab Links your account: your comments, reviews, merges and closes post under your Slack name and avatar. A 404 on the GitHub link: FAQ
unlink github / unlink gitlab Unlinks it

Documentation

Guide Covers
Setup from scratch (Markdown) Every step to a running bot, on your machine with ngrok
Using mitten Tracking, what gets posted, commands, linking
Slack app setup The manifest, secrets, custom emoji, scopes
GitHub setup The GitHub App, permissions, events, Enterprise Server
GitLab setup Webhook, access token, OAuth application, self-managed
Deployment Compose, TLS, migrations, upgrades, backups, replicas
Admin console The optional admin UI
MCP server Ask an AI assistant about mitten, or have it act, through /admin
Regression checklist Every feature as a manual test step
Architecture (Markdown) How the pieces fit
Concepts The vocabulary used in the code

FAQ and ideas

  • FAQ: known limits and why they stay.
  • Ideas: features not built, kept for when a team needs them.

Star history

Star History Chart

Contributing and license

Contributions are welcome; CONTRIBUTING.md covers the setup, the checks and how to add a provider. mitten is MIT-licensed; see LICENSE.

About

Self-hosted Slack bot that syncs GitHub pull requests and GitLab merge requests into Slack threads: paste a link, and every push, review, comment, merge and close posts under it.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0