Skip to content

fix: match webhook repo URLs after normalization and redeploy failed apps - #128

Merged
coderbuzz merged 1 commit into
mainfrom
fix/webhook-repo-match
Nov 10, 2026
Merged

coderbuzz merged 1 commit into
mainfrom
fix/webhook-repo-match

Conversation

@coderbuzz

Copy link
Copy Markdown
Owner

Problem

A push to amg-id/cmsapi-3@staging never redeployed its app. The controller logged:

Webhook: no app found for https://github.com/amg-id/cmsapi-3.git@staging
  • FindAllByGitRepo compared git_repo exactly. The webhook sends clone_url with .git, but the app stored https://github.com/amg-id/cmsapi-3.
  • Even with a match, DeployByGit only redeploys running apps. The app was failed because its first deploy ran before CI had pushed the image (manifest unknown), so webhooks could never bring it back.

Changes

  • normalizeGitRepo (internal/app/gitrepo.go) reduces a URL to host/owner/repo. It strips the scheme, credentials, .git, trailing slash and case, and handles scp-style git@host:path.
  • FindAllByGitRepo filters by branch and non-draft status in SQL, then matches the normalized repo in Go.
  • DeployByGit redeploys apps in running or failed status (webhookDeployable). stopped, deploying, created and draft are still skipped.

Tests

  • TestNormalizeGitRepo: 9 URL variants map to one form, and different repos stay different.
  • TestWebhookDeployable: status table.
  • TestRepo_FindAllByGitRepoNormalizesURL: matches with and without .git; excludes other branch, other repo, draft, and apps with no repo.

go build ./..., go vet ./internal/app/ and go test ./... pass.

Note

If two apps on the same branch had URLs that were treated as different before (one with .git, one without), both are now deployed on push.

🤖 Generated with Claude Code

…apps

GitHub webhooks send clone_url with a ".git" suffix while apps often store
the browser URL without it, so FindAllByGitRepo's exact match found no app
and the push was silently ignored. Repo URLs are now compared as
host/owner/repo (scheme, credentials, ".git", trailing slash and case
stripped; scp-style git@host:path supported).

DeployByGit also redeploys apps in "failed" status, so an app whose first
deploy failed (e.g. image not pushed yet) recovers on the next push.
Stopped apps are still skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderbuzz
coderbuzz merged commit 373ed00 into main Nov 10, 2026
1 check passed
@coderbuzz
coderbuzz deleted the fix/webhook-repo-match branch November 10, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant