Skip to content

Commit 3fcb505

Browse files
authored
CI - Discord PR merge notification includes status of Internal tests check (#1713)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent 35de1ef commit 3fcb505

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

.github/workflows/discord-posts.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,37 @@ jobs:
99
runs-on: ubuntu-latest
1010
if: github.event.pull_request.merged == true &&
1111
github.event.pull_request.base.ref == 'master'
12+
env:
13+
CHECK_NAME: Internal Tests
14+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1215
steps:
16+
- name: Set up GitHub CLI
17+
run: |
18+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /usr/share/keyrings/githubcli-archive-keyring.gpg > /dev/null
19+
sudo apt-get install -y apt-transport-https
20+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list
21+
sudo apt-get update
22+
sudo apt-get install gh
23+
24+
- name: Fetch Check Run Results
25+
run: |
26+
RESULT="$(gh pr checks "${{github.event.pull_request.html_url}}" --json 'name,state' |
27+
jq -r ".[] | select(.name==\"${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+
1335
- name: Send Discord notification
1436
env:
1537
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
1638
PR_TITLE: ${{ github.event.pull_request.title }}
1739
PR_NUMBER: ${{ github.event.pull_request.number }}
1840
PR_URL: ${{ github.event.pull_request.html_url }}
41+
CHECK_RESULT: ${{ env.CHECK_RESULT }}
1942
run: |
2043
curl -X POST -H 'Content-Type: application/json' -d '{
21-
"content": "'"PR merged: [(#${PR_NUMBER}) ${PR_TITLE}](${PR_URL})"'"
44+
"content": "'"PR merged: [(#${PR_NUMBER}) ${PR_TITLE}](${PR_URL})\\n${CHECK_NAME} result: ${CHECK_RESULT}"'"
2245
}' ${DISCORD_WEBHOOK_URL}

0 commit comments

Comments
 (0)