Repository navigation
Add wait_for_completion option to poll build status - #5
Merged
Merged
Conversation
A build that Unity cancels while it is still queued — the common case when
a tag push and a branch push both aim at the same build target — left the
workflow green, because the action returned as soon as the build was
accepted and never looked at it again.
Add an opt-in `wait_for_completion` mode that polls
`GET .../builds/{number}` until the build reaches a terminal state and
fails the step unless it succeeded. Queue reasons are logged as they
change, and a cancellation is explained from the API's `canceledBy` field,
which is the only thing distinguishing a queue timeout from a billing
problem, a bad target configuration or somebody pressing cancel.
Status polling is a GET, so unlike the trigger it is safe to retry:
transient errors are retried five consecutive times, while 401/403 fails
immediately since a service account that cannot read builds will not start
being able to. Giving up on the wait never cancels the Unity build.
Also expose `queued_reason`, `final_build_status` and `canceled_by` as
outputs, and document the canceled-while-queued case in the README.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
A real canceled build came back with `canceledBy: null` and no checkout time, which the previous message dismissed as "Unity did not report a reason" — the least useful thing to say about the case that turns out to be common. Read `checkoutStartTime` alongside `canceledBy`: a cancellation with no attribution and no checkout means the build died in the queue, which is what a superseding build for the same target looks like. Say that, and point at the build list that confirms it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
The build list for the affected target shows build 4 waiting alone: no other build was created while it queued, so "another build superseded it" was the wrong story to tell with confidence. Say what the data actually supports — the build was killed waiting for a machine, which the workflow cannot cause — and list the checks that distinguish the causes instead of asserting one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
The build object carries a `links.auditlog` URL, and that log is where Unity records what acted on the build — the one place that can name a canceller when `canceledBy` comes back null, as it does for builds killed while queued. Fetch it best-effort after a cancellation: a failure there must not replace the cancellation message with a plumbing error. Follow the link only when it stays on the configured API origin, so a link from a response body can never carry the Basic credential to another host. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
Builds do carry a `links.auditlog` href, but requesting it with working credentials on a real build returns `404 Not Found` (error code 54) — the link is a leftover that v2 never implemented. The fetch could therefore only ever fail silently. This reverts commit 2a4ba0f and records the dead end in the README so the next person does not chase the same link. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
Whether a queued build is waiting its turn behind another build or waiting for a machine that may never arrive is the single most useful thing to know about a build that later dies in the queue, and the trigger response already carries it. Put it in the summary table when present, so it is visible without opting into the wait. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the ability to wait for a Unity Cloud Build to reach a terminal state before the action completes, allowing workflows to fail if the build doesn't succeed. Previously, the action would return immediately after queuing the build, even if Unity later canceled it.
Key Changes
wait_for_completion: Boolean flag (defaultfalse) to enable polling the build status until completionpoll_interval_seconds: Controls polling frequency (default30, minimum5to avoid API hammering)timeout_minutes: Maximum time to wait before failing the step (default90,0for indefinite)queued_reason: Why the build is waiting (e.g.,targetConcurrency,waitingForBuildAgent)final_build_status: Terminal status of the build (success,failure,canceled,unknown)canceled_by: Reason the build was canceled (e.g.,concurrency-timelimit,billing-invalidsubscription)parse_bool()andparse_uint()to validate and normalize inputs before useImplementation Details
wait_for_completionis explicitly enabled, maintaining backward compatibilityGETrequests, unlike the initial build triggercanceledByvalues to human-readable explanationshttps://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp