-
Notifications
You must be signed in to change notification settings - Fork 2
feat(trogon-source-linear): add Linear webhook receiver #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
devops/docker/compose/services/trogon-source-linear/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # ── Stage 1: chef — generate dependency recipe ────────────────────────────── | ||
| FROM rust:1.93-slim AS chef | ||
|
|
||
| RUN cargo install cargo-chef --locked | ||
|
|
||
| WORKDIR /build | ||
|
|
||
| # ── Stage 2: planner — capture dependency graph ───────────────────────────── | ||
| FROM chef AS planner | ||
|
|
||
| COPY Cargo.toml Cargo.lock ./ | ||
| COPY crates/ crates/ | ||
|
|
||
| RUN cargo chef prepare --recipe-path recipe.json | ||
|
|
||
| # ── Stage 3: builder — cached dependency build + final compile ────────────── | ||
| FROM chef AS builder | ||
|
|
||
| COPY --from=planner /build/recipe.json recipe.json | ||
| RUN cargo chef cook --release --recipe-path recipe.json -p trogon-source-linear | ||
|
|
||
| COPY Cargo.toml Cargo.lock ./ | ||
| COPY crates/ crates/ | ||
|
|
||
| RUN cargo build --release -p trogon-source-linear && \ | ||
| strip target/release/trogon-source-linear | ||
|
|
||
| # ── Stage 4: runtime ──────────────────────────────────────────────────────── | ||
| FROM debian:bookworm-20250317-slim AS runtime | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| ca-certificates curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN useradd --no-create-home --shell /usr/sbin/nologin trogon | ||
|
|
||
| COPY --from=builder /build/target/release/trogon-source-linear /usr/local/bin/trogon-source-linear | ||
|
|
||
| USER trogon | ||
|
|
||
| EXPOSE 8080 | ||
|
|
||
| STOPSIGNAL SIGTERM | ||
|
|
||
| ENTRYPOINT ["/usr/local/bin/trogon-source-linear"] |
72 changes: 72 additions & 0 deletions
72
devops/docker/compose/services/trogon-source-linear/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Receiving Linear Webhooks Locally | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Docker Compose | ||
| - A [Linear](https://linear.app) workspace with admin access | ||
| - An [ngrok](https://ngrok.com) account (free tier works) | ||
|
|
||
| ## 1. Get your ngrok tunnel URL | ||
|
|
||
| Start only ngrok and NATS to obtain a public URL before configuring Linear: | ||
|
|
||
| ```bash | ||
| docker compose --profile dev up ngrok nats | ||
| ``` | ||
|
|
||
| Find the tunnel URL in the ngrok container logs: | ||
|
|
||
| ```bash | ||
| docker compose logs ngrok | ||
| ``` | ||
|
|
||
| Look for the `linear` tunnel URL (e.g. `https://abc123.ngrok-free.app`). | ||
|
|
||
| ## 2. Configure your Linear webhook | ||
|
|
||
| 1. Go to **Settings → API → Webhooks** | ||
| 2. Click **New webhook** | ||
| 3. Set: | ||
| - **URL**: `https://<ngrok-url>/webhook` | ||
| 4. Select the resource types you want to receive events for | ||
| 5. Save | ||
| 6. Copy the **signing secret** that Linear generates | ||
|
|
||
| ## 3. Start the webhook receiver | ||
|
|
||
| Set `LINEAR_WEBHOOK_SECRET` in your `.env` to the signing secret from step 2, | ||
| then bring up the full stack: | ||
|
|
||
| ```bash | ||
| docker compose --profile dev up | ||
| ``` | ||
|
|
||
| ## 4. Verify | ||
|
|
||
| Trigger an event in Linear (e.g. create an issue). You should see: | ||
|
|
||
| - The webhook receiver log the incoming event | ||
| - The event published to NATS on `linear.{type}.{action}` | ||
|
|
||
| You can inspect NATS with: | ||
|
|
||
| ```bash | ||
| nats sub -s nats://nats.trogonai.orb.local:4222 "linear.>" | ||
| ``` | ||
|
|
||
| Without `--profile dev`, ngrok is excluded and only the core services start. | ||
|
|
||
| ## Environment variables | ||
|
|
||
| | Variable | Required | Default | Description | | ||
| |---|---|---|---| | ||
| | `LINEAR_WEBHOOK_SECRET` | yes | — | Signing secret from Linear's webhook settings | | ||
| | `NGROK_AUTHTOKEN` | yes (dev profile) | — | ngrok auth token | | ||
| | `LINEAR_WEBHOOK_PORT` | no | `8080` | HTTP port for the webhook receiver | | ||
| | `LINEAR_SUBJECT_PREFIX` | no | `linear` | NATS subject prefix | | ||
| | `LINEAR_STREAM_NAME` | no | `LINEAR` | JetStream stream name | | ||
| | `LINEAR_STREAM_MAX_AGE_SECS` | no | `604800` | Max message age in seconds (7 days) | | ||
| | `LINEAR_WEBHOOK_TIMESTAMP_TOLERANCE_SECS` | no | `60` | Replay-attack window in seconds (0 to disable) | | ||
| | `LINEAR_NATS_ACK_TIMEOUT_MS` | no | `10000` | JetStream ACK timeout in milliseconds | | ||
| | `NATS_URL` | no | `localhost:4222` | NATS server URL(s) | | ||
| | `RUST_LOG` | no | `info` | Log level | |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.