Yes, absolutely it is. However, the GitHub terms of service include the grant of a license to GitHub "to store, archive, parse, and display Your Content, and make incidental copies, as necessary to provide the applications, software, products, and services provided by GitHub, including any Beta Previews" (note this is a synthetic quote, generated by substituting definitions from the "Definitions" section of the ToS for the terms so defined). I expect the Microsoft / GitHub will simply rely on this part of the terms of service; by posting your code, you gave them a license to use it pretty much however they like in the course of their business; the fact that Co-Pilot wasn't conceived at the time the code was posted is irrelevant, as this section of the ToS also includes "including improving the Service [the applications, software, products and services provided by GitHub] over time."
What will be very interesting is how the court treats people who posted someone else's copyleft-licensed code. Such a person has every right to make copies of the code, make derivative works, post it all on the internet etc etc; what they don't have a right to do is to grant a non-copyleft license to GitHub, which they implicitly purport to do when they post it on the site.
It's worth noting that GitHub has separate terms of service for corporate customers. Those terms have a similar license grant, but crucially define "the Service" much more narrowly, as "GitHub's hosted service and any applicable documentation" instead of "the applications, software, products and services provided by GitHub, including any Beta Previews."