Skip to content
Merged
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
36 changes: 28 additions & 8 deletions .github/actions/prebuilt-alert/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ runs:
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
REPO: ${{ github.repository }}
run: |
# GitHub runs `shell: bash` with -e, which `set -uo pipefail` does not
# undo. Alerting must never fail the run it reports on, so turn it off
# explicitly; every gh call below is already individually tolerated.
set +e
set -uo pipefail

# Alerting must never fail the run it reports on, so gh calls are tolerated.
case "$STATUS" in
failure|success) ;;
*) echo "::warning::prebuilt-alert: unknown status '$STATUS'"; exit 0 ;;
Expand Down Expand Up @@ -79,6 +82,16 @@ runs:
"$RUN_URL" \
"$DETAILS")"

# The run summary always works: no token, no permission, no repo
# setting. Issues can be disabled (they are on a fresh fork), and an
# alert nobody can read is the failure this whole pipeline keeps
# having, so write the details somewhere visible before trying.
Comment on lines +85 to +88

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Shorten the run-summary comment

This four-line comment includes incident-specific prose such as "the failure this whole pipeline keeps having" and is excessive for the simple fallback write that follows. Reduce it to a concise explanation that the summary preserves failure details when issue reporting is unavailable.

AGENTS.md reference: AGENTS.md:L63-L63

Useful? React with 👍 / 👎.

{
echo "## ${TITLE}"
echo
echo "$DETAILS"
} >> "${GITHUB_STEP_SUMMARY:-/dev/null}"

if [ -n "$EXISTING" ]; then
# Comment rather than open a second issue, so an outage is one thread.
gh issue comment "$EXISTING" --repo "$REPO" --body "$BODY" >/dev/null 2>&1 \
Expand All @@ -89,11 +102,18 @@ runs:
gh label create "$LABEL" --repo "$REPO" --color B60205 \
--description "Prebuilt release pipeline is failing" >/dev/null 2>&1 || true
NEW="$(gh issue create --repo "$REPO" --title "$TITLE" --label "$LABEL" \
--body "$BODY" 2>/dev/null | tail -1)"
if [ -n "$NEW" ]; then
echo "opened $NEW ($KEY)"
else
# The one case worth shouting about: a real failure went unreported.
echo "::error::prebuilt-alert: could not open an issue for ${KEY}; the failure at ${RUN_URL} is unreported"
fi
--body "$BODY" 2>&1 | tail -1)"
case "$NEW" in
https://*) echo "opened $NEW ($KEY)" ;;
*)
# The one case worth shouting about: a real failure went
# unreported. Name the usual cause so it is actionable.
if [ "$(gh api "repos/${REPO}" --jq .has_issues 2>/dev/null)" = "false" ]; then
echo "::error::prebuilt-alert: issues are disabled on ${REPO}, so ${KEY} cannot be tracked; see the run summary for details"
else
echo "::error::prebuilt-alert: could not open an issue for ${KEY} (${NEW}); the failure at ${RUN_URL} is unreported"
fi
;;
esac
fi
exit 0