From 1bd118f74d8812116bfb76e4f78a6ff053532579 Mon Sep 17 00:00:00 2001 From: tend-agent <270458913+tend-agent@users.noreply.github.com> Date: Tue, 4 Aug 2026 07:16:44 +0000 Subject: [PATCH] fix(report-failure): name the trigger a stranded outage row points at --- shared/steps/report-failure.sh | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/shared/steps/report-failure.sh b/shared/steps/report-failure.sh index cc73608f..e8b1c6ae 100755 --- a/shared/steps/report-failure.sh +++ b/shared/steps/report-failure.sh @@ -16,16 +16,32 @@ LABEL="tend-outage" TITLE="Bot temporarily unavailable" RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" -# Build a one-line reference to the triggering context +# Build a one-line reference to the triggering context. This is the only +# pointer back to the work the failure stranded, so every trigger that +# carries one names it; `// empty` keeps a missing field out of the cell as +# blank rather than the literal `null` jq would otherwise print. REF="" if [ "$GITHUB_EVENT_NAME" = "pull_request_target" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ]; then - PR_NUM=$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH") - REF="#${PR_NUM}" + PR_NUM=$(jq -r '.pull_request.number // empty' "$GITHUB_EVENT_PATH") + REF="${PR_NUM:+#${PR_NUM}}" elif [ "$GITHUB_EVENT_NAME" = "issues" ] || [ "$GITHUB_EVENT_NAME" = "issue_comment" ]; then - ISSUE_NUM=$(jq -r '.issue.number' "$GITHUB_EVENT_PATH") - REF="#${ISSUE_NUM}" + ISSUE_NUM=$(jq -r '.issue.number // empty' "$GITHUB_EVENT_PATH") + REF="${ISSUE_NUM:+#${ISSUE_NUM}}" +elif [ "$GITHUB_EVENT_NAME" = "repository_dispatch" ]; then + # tend-mention relays review events through a secretless job that re-posts + # them as a repository_dispatch, so the PR number arrives in the payload + # rather than in a `pull_request` object. + PR_NUM=$(jq -r '.client_payload.pr // empty' "$GITHUB_EVENT_PATH") + REF="${PR_NUM:+#${PR_NUM}}" elif [ "$GITHUB_EVENT_NAME" = "workflow_run" ]; then - REF="CI fix for workflow run" + # Link the run being fixed — without its id there is no way back to the + # failure the ci-fix job was dispatched to handle. + UPSTREAM_ID=$(jq -r '.workflow_run.id // empty' "$GITHUB_EVENT_PATH") + if [ -n "$UPSTREAM_ID" ]; then + REF="CI fix for [run ${UPSTREAM_ID}](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${UPSTREAM_ID})" + else + REF="CI fix for workflow run" + fi fi TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)