US President Donald Trump illegally ordered the National Guard to Portland, a federal judge has ruled.