It is indeed the duty of civil servants to serve the government of the day, regardless of its political complexion.
When I was a (fairly senior) civil servant I did so, with equal commitment, to the best of my ability, for both Conservative and Labour ministers, advising them on how best to operate the machinery of government to deliver their policies.
That meant on occasion telling a minister what he did not want to hear – ie the financial, administrative or other difficulties that could arise.
On at least three occasions, that led to a “full and frank discussion” with the minister concerned. However, each time he listened carefully, did not assume that I was supporting the opposition, and recognised that it was my duty, as a professional, non-political, civil servant, to raise these difficulties.
I was just doing my job, and thereafter had no difficulty in continuing to work for these ministers.