From 3b34dec0ce35b0e23fcfd5b673c2c6d14c04cbeb Mon Sep 17 00:00:00 2001 From: Massimiliano Mirra Date: Sat, 2 Sep 2023 11:01:24 +0100 Subject: [PATCH 1/3] update github handler --- pkg/http/github_webhook_trigger.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/http/github_webhook_trigger.go b/pkg/http/github_webhook_trigger.go index 5e94fc19..a4673eb0 100644 --- a/pkg/http/github_webhook_trigger.go +++ b/pkg/http/github_webhook_trigger.go @@ -69,7 +69,7 @@ func (s *TriggerServer) githubHandler(resp http.ResponseWriter, req *http.Reques var imageName, imageTag string switch hookEvent { - case "package_v2": + case "package": payload := new(githubPackageV2Webhook) if err := json.NewDecoder(req.Body).Decode(payload); err != nil { log.WithFields(log.Fields{ @@ -143,8 +143,9 @@ func (s *TriggerServer) githubHandler(resp http.ResponseWriter, req *http.Reques return } + // XXX .registry_package.package_version.package_url could work too but it ends with colon imageName = strings.Join( - []string{"docker.pkg.github.com", payload.Repository.FullName, payload.RegistryPackage.Name}, + []string{"ghcr.io", payload.Repository.FullName}, "/", ) imageTag = payload.RegistryPackage.PackageVersion.Version From 6c9f9a00935f6aaaf939fdc28fcf77d4ce0845ee Mon Sep 17 00:00:00 2001 From: Massimiliano Mirra Date: Sat, 2 Sep 2023 11:20:02 +0100 Subject: [PATCH 2/3] fix: update test --- pkg/http/github_webhook_trigger_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/http/github_webhook_trigger_test.go b/pkg/http/github_webhook_trigger_test.go index 064e0604..b8f2cb8f 100644 --- a/pkg/http/github_webhook_trigger_test.go +++ b/pkg/http/github_webhook_trigger_test.go @@ -119,7 +119,7 @@ var fakeGithubPackageWebhook = `{ "about_url": "https://help.github.com/about-github-package-registry", "name": "GitHub docker registry", "type": "docker", - "url": "https://docker.pkg.github.com/DingGGu/UtaiteBOX", + "url": "https://ghcr.io/DingGGu/UtaiteBOX", "vendor": "GitHub Inc" } }, @@ -361,8 +361,8 @@ func TestGithubPackageWebhookHandler(t *testing.T) { t.Fatalf("unexpected number of events submitted: %d", len(fp.submitted)) } - if fp.submitted[0].Repository.Name != "docker.pkg.github.com/DingGGu/UtaiteBOX/server" { - t.Errorf("expected docker.pkg.github.com/DingGGu/UtaiteBOX/server but got %s", fp.submitted[0].Repository.Name) + if fp.submitted[0].Repository.Name != "ghcr.io/DingGGu/UtaiteBOX" { + t.Errorf("expected ghcr.io/DingGGu/UtaiteBOX but got %s", fp.submitted[0].Repository.Name) } if fp.submitted[0].Repository.Tag != "1.2.3" { From 8834bb81ebc983b73da4c0bea323e973e125187b Mon Sep 17 00:00:00 2001 From: Massimiliano Mirra Date: Sat, 2 Sep 2023 14:03:58 +0100 Subject: [PATCH 3/3] fix: update test --- pkg/http/github_webhook_trigger_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/http/github_webhook_trigger_test.go b/pkg/http/github_webhook_trigger_test.go index b8f2cb8f..f8e27ff9 100644 --- a/pkg/http/github_webhook_trigger_test.go +++ b/pkg/http/github_webhook_trigger_test.go @@ -380,7 +380,7 @@ func TestGithubContainerRegistryWebhookHandler(t *testing.T) { if err != nil { t.Fatalf("failed to create req: %s", err) } - req.Header.Set("X-GitHub-Event", "package_v2") + req.Header.Set("X-GitHub-Event", "package") //The response recorder used to record HTTP responses rec := httptest.NewRecorder()