Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
cli/.github/workflows/live-e2e-notify.yml at develop · GMartinho/cli · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
GMartinho
cli
Repository navigation
Code
Pull requests
Projects
Security and quality
Insights
More
items
Files
Expand file tree
develop
Breadcrumbs
cli
/
.github
/
workflows
/
live-e2e-notify.yml
Copy path
View runs
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
123 lines (114 loc) · 6.98 KB
develop
Breadcrumbs
cli
/
.github
/
workflows
/
live-e2e-notify.yml
Copy path
Top
File metadata and controls
Code
Blame
123 lines (114 loc) · 6.98 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name
:
Live E2E Notifications
on
:
workflow_run
:
workflows
:
[Live E2E, Release]
types
:
[completed]
permissions
:
actions
:
read
contents
:
read
jobs
:
notify
:
if
:
github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'success'
runs-on
:
ubuntu-latest
timeout-minutes
:
5
continue-on-error
:
true
steps
:
-
name
:
Notify Slack
env
:
GH_TOKEN
:
${{ github.token }}
REPOSITORY
:
${{ github.repository }}
RUN_ID
:
${{ github.event.workflow_run.id }}
RUN_NUMBER
:
${{ github.event.workflow_run.run_number }}
RUN_ATTEMPT
:
${{ github.event.workflow_run.run_attempt }}
WORKFLOW_ID
:
${{ github.event.workflow_run.workflow_id }}
WORKFLOW_NAME
:
${{ github.event.workflow_run.name }}
SHA
:
${{ github.event.workflow_run.head_sha }}
BRANCH
:
${{ github.event.workflow_run.head_branch }}
CONCLUSION
:
${{ github.event.workflow_run.conclusion }}
SLACK_WEBHOOK
:
${{ secrets.SLACK_RELEASE_WEBHOOK }}
run
:
|
set -euo pipefail
# A reusable suite job is named "Live e2e" or ends with the exact
# " / Live e2e" suffix. Keep this aligned with the producer and gate.
suite_conclusion() {
jq -r '([.jobs[]? | select(.name == "Live e2e" or (.name | endswith(" / Live e2e"))) | .conclusion] | if any(.[]; . == "failure") then "failure" elif any(.[]; . == "success") then "success" else "none" end)'
}
if ! current_jobs="$(gh api --paginate "/repos/${REPOSITORY}/actions/runs/${RUN_ID}/attempts/${RUN_ATTEMPT}/jobs?per_page=100")"; then
echo "::warning::Could not inspect jobs for ${WORKFLOW_NAME} run ${RUN_ID}; suppressing notification because the suite result is unknown."
exit 0
fi
current_suite="$(printf '%s\n' "$current_jobs" | jq -s '{jobs: map(.jobs[])}' | suite_conclusion)"
startup_failure=false
if [[ "$current_suite" == none && "$WORKFLOW_NAME" == "Live E2E" && "$CONCLUSION" == failure ]]; then
current_suite=failure
startup_failure=true
elif [[ "$current_suite" == none || ("$current_suite" == failure && "$WORKFLOW_NAME" == "Release") ]]; then
# Release's generic notification covers release failures and runs
# that reused a staging result without creating a suite job.
exit 0
fi
prior_conclusion=""
if (( RUN_ATTEMPT > 1 )); then
if ! prior_jobs="$(gh api --paginate "/repos/${REPOSITORY}/actions/runs/${RUN_ID}/attempts/$((RUN_ATTEMPT - 1))/jobs?per_page=100")"; then
echo "::warning::Could not inspect the prior attempt for ${WORKFLOW_NAME} run ${RUN_ID}; suppressing transition notification."
exit 0
fi
prior_conclusion="$(printf '%s\n' "$prior_jobs" | jq -s '{jobs: map(.jobs[])}' | suite_conclusion)"
[[ "$prior_conclusion" != none ]] || prior_conclusion=""
fi
if ! history="$(gh api -X GET "/repos/${REPOSITORY}/actions/workflows/${WORKFLOW_ID}/runs" -f "branch=${BRANCH}" -F per_page=25)"; then
if [[ "$current_suite" == success && -z "$prior_conclusion" ]]; then
echo "::warning::Could not inspect recent ${WORKFLOW_NAME} history; suppressing recovery notification."
exit 0
fi
echo "::warning::Could not inspect recent ${WORKFLOW_NAME} history; continuing with the confirmed current result."
else
candidates="$(jq -r --argjson current_number "$RUN_NUMBER" --argjson current_attempt "$RUN_ATTEMPT" '(.workflow_runs // []) | map(select((.run_number != $current_number or (.run_attempt // 1) != $current_attempt) and .status == "completed" and (.conclusion == "failure" or .conclusion == "success"))) | sort_by(.run_number, (.run_attempt // 1)) | reverse | .[] | [.id, (.run_attempt // 1), .run_number, .conclusion] | @tsv' <<< "$history")"
while IFS=$'\t' read -r candidate_id candidate_attempt candidate_number candidate_conclusion; do
[[ -z "$candidate_id" ]] && continue
if (( candidate_number > RUN_NUMBER || (candidate_number == RUN_NUMBER && candidate_attempt > RUN_ATTEMPT) )); then
relation=newer
else
relation=older
fi
if [[ "$relation" == newer || -z "$prior_conclusion" ]]; then
if ! candidate_jobs="$(gh api --paginate "/repos/${REPOSITORY}/actions/runs/${candidate_id}/attempts/${candidate_attempt}/jobs?per_page=100")"; then
echo "::warning::Could not inspect candidate run ${candidate_id}; suppressing notification because history is incomplete."
exit 0
fi
candidate_suite="$(printf '%s\n' "$candidate_jobs" | jq -s '{jobs: map(.jobs[])}' | suite_conclusion)"
if [[ "$candidate_suite" == none && "$WORKFLOW_NAME" == "Live E2E" && "$candidate_conclusion" == failure ]]; then
candidate_suite=failure
fi
if [[ "$candidate_suite" == failure || "$candidate_suite" == success ]]; then
if [[ "$relation" == newer ]]; then
echo "A newer completed relevant suite exists; suppressing stale notification."
exit 0
fi
prior_conclusion="$candidate_suite"
break
fi
fi
done <<< "$candidates"
fi
if [[ "$current_suite" == success ]]; then
[[ "$prior_conclusion" == failure ]] || exit 0
header="✅ Live E2E recovered"
text="Live E2E recovered"
detail="The previous relevant ${WORKFLOW_NAME} live suite failed; this run passed."
else
[[ "$prior_conclusion" != failure ]] || exit 0
if [[ "$startup_failure" == true ]]; then
header="❌ Live E2E failed to start"
text="Live E2E failed to start"
detail="The Live E2E workflow failed before it produced a Live e2e job."
else
header="❌ Live E2E failed"
text="Live E2E failed"
detail="The ${WORKFLOW_NAME} live suite failed."
fi
fi
run_url="https://github.com/${REPOSITORY}/actions/runs/${RUN_ID}"
commit_url="https://github.com/${REPOSITORY}/commit/${SHA}"
payload="$(jq -n --arg text "$text" --arg header "$header" --arg detail "$detail" --arg run_url "$run_url" --arg commit_url "$commit_url" --arg branch "$BRANCH" --arg sha "${SHA:0:7}" '{text:$text,blocks:[{type:"header",text:{type:"plain_text",text:$header,emoji:true}},{type:"section",text:{type:"mrkdwn",text:($detail + "\n*Branch:* `" + $branch + "`\n*Commit:* <" + $commit_url + "|" + $sha + ">\n*Workflow run:* <" + $run_url + "|view logs and failed tests>")}}]}')"
curl -fsSL -X POST -H 'Content-type: application/json' --data "$payload" "$SLACK_WEBHOOK"
You can’t perform that action at this time.