Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion internal/scaffold/fullsend-repo/.github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# lint-workflow-size: max-lines=390
# lint-workflow-size: max-lines=415
# Dispatcher workflow that routes events to agent workflows based on stage.
# Routing logic determines the stage from event context — the shim only
# forwards the raw event. Adding a new stage requires only a case branch
Expand Down Expand Up @@ -324,6 +324,29 @@ jobs:
comment: (.comment // null | if . then {body: .body[:4096]} else null end)
}' "$GITHUB_EVENT_PATH")

# Deduplicate retro dispatches — if a retro workflow run is
# already queued or in-progress for the same source repo + PR,
# skip this dispatch. Multiple shim runs for the same PR close
# event each call dispatch independently; this check prevents
# all but the first from launching a redundant retro run.
if [[ "$STAGE" == "retro" ]]; then
RETRO_PR=$(echo "$EVENT_PAYLOAD" | jq -r '(.pull_request.number // .issue.number) | tostring')
if [[ -n "$RETRO_PR" && "$RETRO_PR" != "null" ]]; then
ACTIVE_IDS=$(gh api "repos/${DISPATCH_REPO}/actions/workflows/retro.yml/runs?per_page=10" \
--jq '[.workflow_runs[] | select(.status == "queued" or .status == "in_progress") | .id] | .[]' 2>/dev/null || true)
for rid in $ACTIVE_IDS; do
RUN_INPUTS=$(gh api "repos/${DISPATCH_REPO}/actions/runs/${rid}" --jq '.inputs' 2>/dev/null || echo '{}')
RUN_SRC=$(echo "$RUN_INPUTS" | jq -r '.source_repo // empty')
RUN_PR=$(echo "$RUN_INPUTS" | jq -r '.event_payload' 2>/dev/null \
| jq -r '(.pull_request.number // .issue.number) | tostring' 2>/dev/null || true)
if [[ "$RUN_SRC" == "$SOURCE_REPO" && "$RUN_PR" == "$RETRO_PR" ]]; then
echo "::notice::Retro already active for ${SOURCE_REPO}#${RETRO_PR} (run ${rid}) — skipping duplicate dispatch"
exit 0
fi
done
fi
fi

echo "Scanning for workflows with stage: $STAGE"

dispatched=0
Expand Down
Loading