func WatchBuilds(ctx context.Context, msg *pubsub.Message) error {
	cfg, err := loadConfig()
	if err != nil {
		return fmt.Errorf("failed loading config: %v", err)
	}

	var build cbpb.Build
	if err := (protojson.UnmarshalOptions{
		AllowPartial:   true,
		DiscardUnknown: true,
	}).Unmarshal(msg.Data, &build); err != nil {
		return err
	}

	log.Printf("Got message about build %s with status %s", build.Id, build.Status)

	if err := cfg.checkEmail(&build); err != nil {
		log.Print("Not sending email: ", err)
	} else if err := sendEmail(ctx, cfg, &build); err != nil {
		log.Print("Failed sending email: ", err)
	}

	if err := cfg.checkBadge(&build); err != nil {
		log.Print("Not writing badge: ", err)
	} else if err := writeBadge(ctx, cfg, &build); err != nil {
		log.Print("Failed writing badge: ", err)
	}

	return nil
}
// WatchBuilds is a Cloud Function that processes Pub/Sub messages sent by Cloud Build.
WatchBuilds is a Cloud Function that processes Pub/Sub messages sent by Cloud Build.
// WatchBuilds is a Cloud Function that processes Pub / Sub messages sent by Cloud Build .
func WatchBuilds(ctx context.Context, msg *pubsub.Message) error {
	cfg, err := loadConfig()
	if err != nil {
		return fmt.Errorf("failed loading config: %v", err)
	}
	var build cbpb.Build
	if err := (protojson.UnmarshalOptions{
		AllowPartial:   true,
		DiscardUnknown: true,
	}).Unmarshal(msg.Data, &build); err != nil {
		return err
	}
	log.Printf("Got message about build %s with status %s", build.Id, build.Status)
	if err := cfg.checkEmail(&build); err != nil {
		log.Print("Not sending email: ", err)
	} else if err := sendEmail(ctx, cfg, &build); err != nil {
		log.Print("Failed sending email: ", err)
	}
	if err := cfg.checkBadge(&build); err != nil {
		log.Print("Not writing badge: ", err)
	} else if err := writeBadge(ctx, cfg, &build); err != nil {
		log.Print("Failed writing badge: ", err)
	}
	return nil
}
func WatchBuilds ( ctx context . Context , msg * pubsub . Message ) error { cfg , err := loadConfig ( ) if err != nil { return fmt . Errorf ( " " , err ) } var build cbpb . Build if err := ( protojson . UnmarshalOptions { AllowPartial : true , DiscardUnknown : true , } ) . Unmarshal ( msg . Data , & build ) ; err != nil { return err } log . Printf ( " " , build . Id , build . Status ) if err := cfg . checkEmail ( & build ) ; err != nil { log . Print ( " " , err ) } else if err := sendEmail ( ctx , cfg , & build ) ; err != nil { log . Print ( " " , err ) } if err := cfg . checkBadge ( & build ) ; err != nil { log . Print ( " " , err ) } else if err := writeBadge ( ctx , cfg , & build ) ; err != nil { log . Print ( " " , err ) } return nil }
WatchBuilds is a Cloud Function that processes Pub/Sub messages sent by Cloud Build.
WatchBuilds is a Cloud Function that processes Pub / Sub messages sent by Cloud Build .