forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (51 loc) · 1.83 KB
/
cloud-test-pr-reporter.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
name: Report Cloud Test Status
on:
repository_dispatch:
types:
# These two come from cloud-test-pr-workflow-run.yml which does the remote dispatch in the
# wildfly-cloud-tests repository
- report-cloud-tests-workflow-run-pending
- report-cloud-tests-workflow-run-failed
# These two come from the remote job in the wildfly-cloud-tests repository
- report-cloud-tests-pr-pending
- report-cloud-tests-pr-complete
env:
DESC: ${{ github.event.client_payload.desc }}
GH_TOKEN: ${{ github.token }}
PR_HEAD_SHA: ${{ github.event.client_payload.prHeadSha }}
RUN_URL: ${{ github.event.client_payload.runUrl }}
STATE: ${{ github.event.client_payload.state }}
jobs:
reporter:
permissions:
checks: write
statuses: write
runs-on: ubuntu-latest
steps:
- name: Output
env:
MESSAGE: ${{ toJSON(github.event.client_payload) }}
run: echo $MESSAGE
- name: Report status
run: |
JSON_STRING=$(jq -c -n \
--arg state "$STATE" \
--arg tgt "$RUN_URL" \
--arg desc "$DESC" \
'{state: $state, target_url: $tgt, description: $desc, context: "Cloud Tests Remote Run"}' )
set -x
resp=$(curl -L -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GH_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/statuses/${PR_HEAD_SHA} \
-d "${JSON_STRING}")
ret=$?
set +x
if [ $ret -eq 0 ]; then
sleep 2
else
echo "Workflow failed to trigger"
echo "$resp"
exit 1
fi