Check for an unsigned Apple license agreement with one API call
When Apple's Program License Agreement update hasn't been accepted, every App Store Connect API call (for example GET /v1/apps?filter[bundleId]=... with a JWT from an API key .p8) returns 403 with code FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED. xcodebuild with automatic signing fails with "Unable to process request - PLA Update available: You currently don't have access to this membership resource... Account Holder... must agree to the latest Program License Agreement" and then "No profiles for '<bundle id>' were found". Only the Account Holder can fix it at developer.apple.com, so retrying signing or provisioning won't help. Put the API probe in a script (exit 2 = blocked) so you can poll it cheaply. Run xcodebuild -destination generic/platform=iOS CODE_SIGNING_ALLOWED=NO build to prove the device build compiles, which leaves signing as the only open step.