Previous threads we've done: https://news.ycombinator.com/submitted?id=proberts.
I suspect it would be important that any funds never reached you, so you couldn't simply receive money then donate that amount. Playing a charity gig where the receipts go directly to the charity would likely be fine, streaming/Spotify revenue I don't know, acting in a movie might be out of the question if it's being professionally shot because the producer might have insurance or other requirements that only paid performers and crew can be on set, etc.
However the practical answer is ask. Some visas like the J1 allow this - even consulting, provided it meets a bunch of criteria and relevant people sign off. It's not a trivial process, but it's not outright forbidden.