From military.com —
Federal law requires everyone who enlists or re-enlists in the Armed Forces of the United States to take the enlistment oath. The oath of enlistment into the United States Armed Forces is administered by any commissioned officer to any person enlisting or re-enlisting for a term of service into any branch of the military. The officer asks the person, or persons, to raise their right hand and repeat the oath after him. The oath is traditionally performed in front of the United States Flag and other flags, such as the state flag, military branch flag, and unit guidon may be present.
In the Armed Forces EXCEPT the National Guard (Army or Air)
I, (NAME), do solemnly swear (or affirm) that I will support and defend the Constitution of the United States against all enemies, foreign and domestic; that I will bear true faith and allegiance to the same; and that I will obey the orders of the President of the United States and the orders of the officers appointed over me, according to regulations and the Uniform Code of Military Justice. So help me God.
In the National Guard (Army or Air)
I, (NAME), do solemnly swear (or affirm) that I will support and defend the Constitution of the United States and the State of (STATE NAME) against all enemies, foreign and domestic; that I will bear true faith and allegiance to the same; and that I will obey the orders of the President of the United States and the Governor of (STATE NAME) and the orders of the officers appointed over me, according to law and regulations. So help me God.
I, (state your name), having been appointed a (rank) in the United States (branch of service), do solemnly swear (or affirm) that I will support and defend the Constitution of the United States against all enemies, foreign and domestic; that I will bear true faith and allegiance to the same; that I take this obligation freely, without any mental reservation or purpose of evasion; and that I will well and faithfully discharge the office upon which I am about to enter. So help me God.
That's the Oath I took and the one I will follow. An Oath is Forever.
Plus the oath is to obey the orders of the President, not some ineligible usurper.
And who decides when an order is illegal or the order giver is a usurper?
Well basically, each person does. But they'd better be very certain of that decision. The penalty for deciding wrongly is severe.