Why would running code on a github action runner that's built to run code be against ToS?
If it was, I'm sure they'd ban the marketplace extensions that make it absolutely trivial to do this: https://github.com/marketplace/actions/debugging-with-ssh
Instances where an air gapped build machine doesn't work are examples of developer laziness, not bothering to properly document dependencies.
The number of packages that is malicious is high enough, then you have typo packages, and packages that get compromised at a later date. Being isolated from the net with proper monitoring gives a huge heads up when your build system suddenly tries to contact some random site/IP.
You're far more likely to encounter a security issue from adding/upgrading a dependency than your build process requiring internet access.