Either use border-image: linear-gradient(...) 1, or the more common "double background" trick — one background on padding-box (the real fill colour) and a gradient on border-box, so the gradient only shows through the border's thickness. The double-background version plays nicer with border-radius, so it's more widely used.
Continuously rotating the gradient's angle with JS produces an animated border that looks like light sweeping around the edge.
When to use
Use for highlighted cards, "featured" badges, active-tab indicators. Using several on one screen flattens the hierarchy — use it sparingly.