-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (52 loc) · 2.36 KB
/
send-test-results.yml
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
name: Send check results to CodeX chat
on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
types: [opened, synchronize, reopened]
jobs:
send-message:
permissions:
actions: write
runs-on: ubuntu-22.04
env:
API_URL: "https://api.github.com/repos/${{ github.repository }}/actions/runs"
steps:
- name: Set commit_sha to pull request head sha and ref to pull request
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "REF=[${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})" >> $GITHUB_ENV
- name: Set commit_sha to pushed commit sha and ref to branch name
if: ${{ github.event_name == 'push' }}
run: |
echo "COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV
echo "REF=[${{ github.ref_name }}](https://github.com/${{ github.repository }}/tree/${{ github.ref }})" >> $GITHUB_ENV
- name: Wait for other checks to succeed
uses: lewagon/[email protected]
with:
ref: ${{ env.COMMIT_SHA }}
running-workflow-name: send-message
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 3
allowed-conclusions: success,skipped,cancelled,failure
# Find results of the actions with the same SHA as this action via github api and set them to env variable
- name: Get actions results
run: |
echo 'ACTIONS_RESULTS<<0x0a' >> $GITHUB_ENV
echo -e "**api** 👏 ${{ github.triggering_actor }}:\n${{ env.REF }}\n" >> $GITHUB_ENV
curl -s -X GET -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"\
"$API_URL" | jq -r '.workflow_runs[] | select(((.head_sha=="${{ env.COMMIT_SHA }}") and (.id != ${{ github.run_id }}))
and ((.conclusion == "success") or (.conclusion == "failure"))) | "\(.conclusion) [\(.name)](\(.html_url))" |
gsub("success"; "✅") | gsub("failure"; "❌")' >> $GITHUB_ENV
echo '0x0a' >> $GITHUB_ENV
- name: Send a message
uses: codex-team/action-codexbot-notify@v1
with:
webhook: ${{ secrets.CODEX_BOT_NOTIFY_NOTES_CHAT }}
message: "${{ env.ACTIONS_RESULTS }}"
parse_mode: 'markdown'
disable_web_page_preview: true