Skip to content

Commit d81950b

Browse files
authored
fix: publish migrate image (#423)
1 parent e530f39 commit d81950b

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

.github/workflows/docker-publish.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ env:
2626
REGISTRY: ghcr.io
2727
# github.repository as <account>/<repo>
2828
IMAGE_NAME: ${{ github.repository }}
29+
MIGRATE_IMAGE_NAME: ${{ github.repository }}-migrate
2930

3031
jobs:
3132
build:
@@ -85,6 +86,19 @@ jobs:
8586
type=semver,pattern={{major}}
8687
type=raw,value=latest,enable={{is_default_branch}}
8788
89+
- name: Extract Docker metadata (migrate)
90+
id: meta-migrate
91+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
92+
with:
93+
images: ${{ env.REGISTRY }}/${{ env.MIGRATE_IMAGE_NAME }}
94+
tags: |
95+
type=ref,event=branch
96+
type=ref,event=pr
97+
type=semver,pattern={{version}}
98+
type=semver,pattern={{major}}.{{minor}}
99+
type=semver,pattern={{major}}
100+
type=raw,value=latest,enable={{is_default_branch}}
101+
88102
# Extract version from git tag or ref
89103
# Uses git describe to get latest tag + commit hash in SemVer format: 1.2.3+abc1234
90104
- name: Extract version
@@ -138,6 +152,22 @@ jobs:
138152
cache-from: type=gha
139153
cache-to: type=gha,mode=max
140154

155+
- name: Build and push migrate Docker image
156+
id: build-and-push-migrate
157+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
158+
with:
159+
context: .
160+
file: apps/web/Dockerfile
161+
target: migrate
162+
push: ${{ github.event_name != 'pull_request' }}
163+
platforms: linux/amd64,linux/arm64
164+
tags: ${{ steps.meta-migrate.outputs.tags }}
165+
labels: ${{ steps.meta-migrate.outputs.labels }}
166+
build-args: |
167+
APP_VERSION=${{ steps.version.outputs.version }}
168+
cache-from: type=gha
169+
cache-to: type=gha,mode=max
170+
141171
# Sign the resulting Docker image digest except on PRs.
142172
# This will only write to the public Rekor transparency log when the Docker
143173
# repository is public to avoid leaking data. If you would like to publish
@@ -152,3 +182,10 @@ jobs:
152182
# This step uses the identity token to provision an ephemeral certificate
153183
# against the sigstore community Fulcio instance.
154184
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
185+
186+
- name: Sign the published migrate Docker image
187+
if: ${{ github.event_name != 'pull_request' }}
188+
env:
189+
TAGS: ${{ steps.meta-migrate.outputs.tags }}
190+
DIGEST: ${{ steps.build-and-push-migrate.outputs.digest }}
191+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

packages/api/src/utils/webhook.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import crypto from "crypto";
22
import { z } from "zod";
33

44
import type { dbClient } from "@kan/db/client";
5-
import * as webhookRepo from "@kan/db/repository/webhook.repo";
65
import type { WebhookEvent } from "@kan/db/schema";
6+
import * as webhookRepo from "@kan/db/repository/webhook.repo";
77

88
export type WebhookEventType = WebhookEvent;
99

@@ -92,7 +92,7 @@ export const webhookUrlSchema = z
9292
(url) => {
9393
try {
9494
const hostname = new URL(url).hostname.toLowerCase();
95-
const ipv4Match = hostname.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
95+
const ipv4Match = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(hostname);
9696
if (ipv4Match) {
9797
const [, a, b] = ipv4Match.map(Number);
9898
if (
@@ -185,15 +185,16 @@ export async function sendWebhooksForWorkspace(
185185
payload: WebhookPayload,
186186
): Promise<void> {
187187
try {
188-
// Get active webhooks for this workspace, pre-filtered by event at the DB level
189-
const webhooks = await webhookRepo.getActiveByWorkspaceId(
190-
db,
191-
workspaceId,
192-
payload.event,
188+
// Get active webhooks for this workspace
189+
const webhooks = await webhookRepo.getActiveByWorkspaceId(db, workspaceId);
190+
191+
// Filter webhooks that are subscribed to this specific event
192+
const webhooksForEvent = webhooks.filter((webhook) =>
193+
webhook.events.includes(payload.event),
193194
);
194195

195-
// Send to all webhooks in parallel (fire and forget)
196-
const promises = webhooks.map((webhook) =>
196+
// Send to all subscribed webhooks in parallel (fire and forget)
197+
const promises = webhooksForEvent.map((webhook) =>
197198
sendWebhookToUrl(webhook.url, webhook.secret ?? undefined, payload).then(
198199
(result) => {
199200
if (!result.success) {

0 commit comments

Comments
 (0)