Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
Signed-off-by: encalada <[email protected]>
  • Loading branch information
qu1queee committed Jun 28, 2024
1 parent 534ecde commit 8e7ac03
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
24 changes: 24 additions & 0 deletions github-webhook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Integrating IBM Cloud Code Engine with Github and Event Notifications

Automating software deployment upon changes in your Git repository isn't a novel idea. In IBM Cloud Code Engine, we provide samples like [Github](https://github.com/IBM/CodeEngine/tree/main/github) or [Github Action Workflows](https://github.com/IBM/CodeEngine/tree/main/github-action-workflows), enabling users to respond to changes in their repositories through Code Engine workloads.

Given the importance of automated continuous deployments for cloud-native applications, this blog post delves deeper into the topic and proposes a new architecture.

By integrating, Git, Code Engine and IBM Cloud [Event Notifications](https://cloud.ibm.com/docs/event-notifications?topic=event-notifications-getting-started), we can offer users an end-to-end workflow from changes in Git to notifications across multiple destinations, including a Code Engine Job.

## Architecture

Our starting point is Git. Cloud Native Applications code is commonly hosted in version control systems like Git. Through Github [webhooks](https://docs.github.com/en/webhooks), changes such as `push` events(_e.g. commiting to your main branch_) can trigger integrations to take responsive actions.

Knowing when these events occur leads us to the question; what actions can we take? Before addressing this, let's consider who should be notified about such actions.


## Using IBM Cloud Event Notifications


## Tell me more!

## Try It!



17 changes: 8 additions & 9 deletions github-webhook/cmd/builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func main() {
l.Info("non knative services found, that match the image output", "namespace", ns, "image", imageOutput)
} else {
l.Info("A matching knative service was found", "namespace", ns, "image", imageOutput)
deleteService(ctx, servingClient, svc)
updateService(ctx, servingClient, svc)
}
}

Expand Down Expand Up @@ -229,22 +229,21 @@ func findService(ctx context.Context, servingClient *serving.ServingV1Client, na
return nil, err
}

for i := range services.Items {
var service = services.Items[i]

if userImage, ok := service.Annotations[userImageAnnotation]; ok {
if userImage == image {
return &service, nil
for _, ksvc := range services.Items {
if len(ksvc.Spec.Template.Spec.Containers) > 0 {
userContainer := ksvc.Spec.Template.Spec.Containers[0]
if userContainer.Image == image {
return &ksvc, nil
}
}
}

return nil, nil
}

func deleteService(ctx context.Context, servingClient *serving.ServingV1Client, service *servingv1.Service) {
func updateService(ctx context.Context, servingClient *serving.ServingV1Client, service *servingv1.Service) {
l := *logger
l.Info("deleting Knative servive to force a new revision", "namespace", service.Namespace, "name", service.Name)
l.Info("updating Knative servive to force a new revision", "namespace", service.Namespace, "name", service.Name)

annotations := service.Spec.Template.GetAnnotations()
if annotations == nil {
Expand Down

0 comments on commit 8e7ac03

Please sign in to comment.