Edit for the updated question: No, a riff does not have to stay within the same scale; you can change the scale (or not use a scale at all) to create a riff.
Original Answer Below
Maybe a more correct question (i.e., not opinion-based) would have been "what is a riff," and that could have then progressed to whether your excerpt is correct.
Mark Spicer has a great article called “(Ac)cumulative Form in Pop-Rock Music”, and he defines a riff as "a distinctive melodic/rhythmic idea in the manner of an ostinato." (An "ostinato" is just a repeated figure.)
Thus it seems you have a three-bar idea that's then repeated, with a slight variation in the melody in measures 4--6. (So it might be a six-bar riff, depending on how you repeat it.)
We can't answer whether it's "good" or not---that's ultimately your call!---but I would suggest reading up a bit on keys and note spellings; I think you'd be better off spelling all of your sharps as flats (D♯ becomes E♭, etc.), because it looks like you're aiming for C minor.