-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.sh
93 lines (80 loc) · 1.7 KB
/
report.sh
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
set -e
SHA8=$(echo $SHA | head -c8)
URL=https://github.com/$REPO
cat <<EOF
# Test of \`${REPO}@${SHA8}\` by \`$CONTEXT\`
| | |
|-|-|
| Host | \`$(hostname)\` |
| User | \`$(whoami)\` |
| Date | $(date '+%F %T') |
| Context | \`$CONTEXT\` |
| Repo | [\`$REPO\`]($URL) |
| Commit | [\`$SHA8\`]($URL/commit/$SHA) |
| Deploy | $([ "$DEPLOY_EXITCODE" = 0 ] && echo :white_check_mark: Pass || echo :x: FAIL) |
| Test | $([ "$TEST_EXITCODE" = 0 ] && echo :white_check_mark: Pass || echo :x: FAIL) |
EOF
echo
echo
case "$DEPLOY_EXITCODE" in
"")
echo "## :exclamation: Deploy (DID NOT RUN)"
;;
0)
echo "## :white_check_mark: Deploy (Pass)"
;;
*)
echo "## :x: Deploy (FAIL)"
;;
esac
echo
if [ "$DEPLOY_EXITCODE" -a "$REPORT_DEPLOY_SUMMARY" ]; then
echo "$REPORT_DEPLOY_SUMMARY" | sh
else
echo "Deploy hook exited with code $DEPLOY_EXITCODE"
fi
echo
if [ -r "$DEPLOY_LOG" ]; then
cat <<EOF
<details>
<summary><b>Click to show deployment log</b></summary>
\`\`\`
$(cat "$DEPLOY_LOG")
\`\`\`
</details>
EOF
else
echo _No deployment log captured_
fi
echo
echo
case "$TEST_EXITCODE" in
"")
echo "## :exclamation: Test (DID NOT RUN)"
;;
0)
echo "## :white_check_mark: Test (Pass)"
;;
*)
echo "## :x: Test (FAIL)"
;;
esac
echo
if [ "$TEST_EXITCODE" -a "$REPORT_TEST_SUMMARY" ]; then
echo "$REPORT_TEST_SUMMARY" | sh
else
echo "Test hook exited with code $TEST_EXITCODE"
fi
echo
if [ -r "$TEST_LOG" ]; then
cat <<EOF
<details>
<summary><b>Click to show full test log</b></summary>
\`\`\`
$(cat "$TEST_LOG")
\`\`\`
</details>
EOF
else
echo _No test log captured_
fi