Skip to content

Commit f5bc4c4

Browse files
committed
fix: prefer github owner name for webhook matching
Что: - Инвертирован порядок fallback для GitHub webhook owner: сначала repository.owner.name, затем repository.owner.login. - Обновлен focused regression test для приоритета owner.name и fallback на owner.login. Зачем: - Выполнить maintainer review request в PR #4674 и сохранить совместимость deploy matching для payload без owner.name. Риски: - Не выявлены для push/tag matching; preview pull_request путь использует тот же helper, но отдельным PR-event тестом не покрыт. Проверки: - Команды и результаты: git diff --check -- apps/dokploy/pages/api/deploy/github.ts apps/dokploy/__test__/deploy/github-webhook-handler.test.ts - passed; CI=true corepack pnpm --dir apps/dokploy exec vitest --config __test__/vitest.config.ts run __test__/deploy/github-webhook-handler.test.ts --reporter=verbose - passed, 1 file / 4 tests; CI=true corepack pnpm exec biome check apps/dokploy/pages/api/deploy/github.ts apps/dokploy/__test__/deploy/github-webhook-handler.test.ts - exit 0, reported existing Number.parseInt radix info at github.ts:464; mandatory QA subagent Boyle - pass. - Ограничения: repo-wide format-and-lint, typecheck, build, and test не запускались для этого точечного review fix. What: - Inverted the GitHub webhook owner fallback order to prefer repository.owner.name before repository.owner.login. - Updated the focused regression test for owner.name precedence and owner.login fallback. Why: - Address the maintainer review request in PR #4674 while preserving deploy matching for payloads without owner.name. Risks: - None identified for push/tag matching; the preview pull_request path uses the same helper but is not covered by a dedicated PR-event test. Checks: - Commands and results: git diff --check -- apps/dokploy/pages/api/deploy/github.ts apps/dokploy/__test__/deploy/github-webhook-handler.test.ts - passed; CI=true corepack pnpm --dir apps/dokploy exec vitest --config __test__/vitest.config.ts run __test__/deploy/github-webhook-handler.test.ts --reporter=verbose - passed, 1 file / 4 tests; CI=true corepack pnpm exec biome check apps/dokploy/pages/api/deploy/github.ts apps/dokploy/__test__/deploy/github-webhook-handler.test.ts - exit 0, reported existing Number.parseInt radix info at github.ts:464; mandatory QA subagent Boyle - pass. - Limitations: repo-wide format-and-lint, typecheck, build, and test were not run for this targeted review fix.
1 parent 54b5626 commit f5bc4c4

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎apps/dokploy/__test__/deploy/github-webhook-handler.test.ts‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ const createResponse = () => {
113113
return res;
114114
};
115115

116-
const createPushRequest = (branch: string) =>
116+
const createPushRequest = (
117+
branch: string,
118+
owner: { login?: string; name?: string } = { login: "agentHits" },
119+
) =>
117120
({
118121
headers: {
119122
"x-hub-signature-256": "sha256=test-signature",
@@ -138,9 +141,7 @@ const createPushRequest = (branch: string) =>
138141
full_name: "agentHits/dokploy",
139142
clone_url: "https://github.com/agentHits/dokploy.git",
140143
html_url: "https://github.com/agentHits/dokploy",
141-
owner: {
142-
login: "agentHits",
143-
},
144+
owner,
144145
},
145146
},
146147
}) as unknown as NextApiRequest;
@@ -194,10 +195,16 @@ describe("GitHub app webhook auto-deploy", () => {
194195
});
195196
});
196197

197-
it("matches push events using repository owner login", async () => {
198+
it("matches push events using repository owner name when available", async () => {
198199
const res = createResponse();
199200

200-
await handler(createPushRequest("main"), res);
201+
await handler(
202+
createPushRequest("main", {
203+
login: "agentHits-login",
204+
name: "agentHits",
205+
}),
206+
res,
207+
);
201208

202209
expect(mocks.queueAdd).toHaveBeenCalledWith(
203210
"deployments",
@@ -215,7 +222,7 @@ describe("GitHub app webhook auto-deploy", () => {
215222
expect(res.json).toHaveBeenCalledWith({ message: "Deployed 1 apps" });
216223
});
217224

218-
it("matches compose push events using repository owner login", async () => {
225+
it("matches compose push events using repository owner login fallback", async () => {
219226
mocks.applicationsFindMany.mockResolvedValue([]);
220227
mocks.composeFindMany.mockImplementation(({ where }) => {
221228
const matches =
@@ -259,7 +266,7 @@ describe("GitHub app webhook auto-deploy", () => {
259266
expect(res.json).toHaveBeenCalledWith({ message: "Deployed 1 apps" });
260267
});
261268

262-
it("matches tag events using repository owner login", async () => {
269+
it("matches tag events using repository owner login fallback", async () => {
263270
mocks.applicationsFindMany.mockImplementation(({ where }) => {
264271
const matches =
265272
getConditionValue(where, "application.sourceType") === "github" &&

‎apps/dokploy/pages/api/deploy/github.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
} from "./[refreshToken]";
2525

2626
const getGithubRepositoryOwner = (githubBody: any) =>
27-
githubBody?.repository?.owner?.login ?? githubBody?.repository?.owner?.name;
27+
githubBody?.repository?.owner?.name ?? githubBody?.repository?.owner?.login;
2828

2929
export default async function handler(
3030
req: NextApiRequest,

0 commit comments

Comments
 (0)