Skip to content

Commit 6e0a752

Browse files
authored
PR merge discord post includes all non-successful checks (#3594)
# Description of Changes Now, the "PR merged" discord post will include all non-successful CI. # API and ABI breaking changes CI-only. # Expected complexity level and risk 2 # Testing Note: I tested this by commenting out / hardcoding some pieces, rather than by actually merging PRs in some other repo. Some test posts it generated: <img width="528" height="266" alt="image" src="https://github.com/user-attachments/assets/27151c5f-216a-47aa-9f3b-74d991bcbbe7" /> <img width="493" height="146" alt="image" src="https://github.com/user-attachments/assets/677de1d5-8268-400c-be16-b3806382bb51" /> --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent 703fae2 commit 6e0a752

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

.github/workflows/discord-posts.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
if: github.event.pull_request.merged == true &&
1111
github.event.pull_request.base.ref == 'master'
1212
env:
13-
CHECK_NAME: Internal Tests
1413
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1514
steps:
1615
- name: Set up GitHub CLI
@@ -21,31 +20,28 @@ jobs:
2120
sudo apt-get update
2221
sudo apt-get install -y gh
2322
24-
- name: Fetch Check Run Results
25-
run: |
26-
RESULT="$(gh pr checks "${{github.event.pull_request.html_url}}" --json 'workflow,state' |
27-
jq -r ".[] | select(.workflow==\"${CHECK_NAME}\").state")"
28-
29-
if [ -z "$RESULT" ]; then
30-
RESULT="The check did not run!"
31-
fi
32-
33-
echo "CHECK_RESULT=${RESULT}" >> $GITHUB_ENV
34-
3523
- name: Send Discord notification
3624
env:
3725
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
3826
PR_TITLE: ${{ github.event.pull_request.title }}
3927
PR_NUMBER: ${{ github.event.pull_request.number }}
4028
PR_URL: ${{ github.event.pull_request.html_url }}
41-
CHECK_RESULT: ${{ env.CHECK_RESULT }}
4229
MENTION_ON_FAILURE: ${{ secrets.DEV_OPS_ROLE_ID }}
4330
run: |
4431
message="PR merged: [(#${PR_NUMBER}) ${PR_TITLE}](<${PR_URL}>)"
45-
message+=$'\n'
46-
message+="${CHECK_NAME} result: ${CHECK_RESULT}"
4732
# Note that anything besides success is treated as a failure (e.g. if the check did not run at all, or if it is still pending).
48-
if [[ "${CHECK_RESULT}" != "SUCCESS" ]]; then
33+
FAILED_CHECKS="$(
34+
gh pr checks "${{github.event.pull_request.html_url}}" \
35+
--json 'workflow,state,name' |
36+
jq '.[] | select(.state != "SUCCESS")' |
37+
jq -r '"\(.workflow) / \(.name): \(.state)"'
38+
)"
39+
message+=$'\n'
40+
if [[ -z "${FAILED_CHECKS}" ]]; then
41+
message+='All checks passed.'
42+
else
43+
message+="${FAILED_CHECKS}"
44+
message+=$'\n'
4945
# This uses special Discord syntax for pinging a particular role.
5046
# Note the '&' - this is the difference between pinging a *role* and pinging a *person*.
5147
message+=" (cc <@&${MENTION_ON_FAILURE}>)"

0 commit comments

Comments
 (0)