Repository navigation
fix: match webhook repo URLs after normalization and redeploy failed apps - #128
Merged
Merged
Conversation
…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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
A push to
amg-id/cmsapi-3@stagingnever redeployed its app. The controller logged:FindAllByGitRepocomparedgit_repoexactly. The webhook sendsclone_urlwith.git, but the app storedhttps://github.com/amg-id/cmsapi-3.DeployByGitonly redeploysrunningapps. The app wasfailedbecause 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 tohost/owner/repo. It strips the scheme, credentials,.git, trailing slash and case, and handles scp-stylegit@host:path.FindAllByGitRepofilters by branch and non-draft status in SQL, then matches the normalized repo in Go.DeployByGitredeploys apps inrunningorfailedstatus (webhookDeployable).stopped,deploying,createdanddraftare 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/andgo 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