Although it's still a net good, I consider it distasteful to do something good solely or mostly for the publicity it brings, especially in cases like this where it took extra effort to publicize it.
Had Elon Musk not made a big deal about it but a media company found out and publicized it, I wouldn't blame him for that.
But he didn't do good, except for himself. What he made was apparently useless.