-
Notifications
You must be signed in to change notification settings - Fork 364
68 lines (57 loc) · 2.15 KB
/
coverage_comment.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
60
61
62
63
64
65
66
67
68
name: Coverage Comment
on:
workflow_run:
workflows: ["Code Coverage"]
types:
- completed
permissions:
pull-requests: write
jobs:
comment:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Use Node.js v20.17 LTS
uses: actions/setup-node@v4
with:
node-version: "20.17"
- name: Download PR Number Artifact
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e #v2.28.0
with:
workflow: "coverage.yml"
run_id: ${{ github.event.workflow_run.id }}
name: pr_number
- name: Download Base Coverage Artifact
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e #v2.28.0
with:
workflow: "coverage.yml"
run_id: ${{ github.event.workflow_run.id }}
name: ref_code_coverage
- name: Download Current Coverage Artifact
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e #v2.28.0
with:
workflow: "coverage.yml"
run_id: ${{ github.event.workflow_run.id }}
name: current_code_coverage
- name: Set PR Number Environment Variables
run: |
echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_ENV
- name: Generate Coverage Comment
run: |
base_coverage=$(cat ref_code_coverage.txt)
current_coverage=$(cat current_code_coverage.txt)
if (( $(echo "$current_coverage < $base_coverage" | bc -l) )); then
icon="❌" # Error icon
else
icon="✅" # Check mark icon
fi
comment_message="**Coverage Report:** $icon<br>Base Coverage: $base_coverage%<br>Current Coverage: $current_coverage%"
echo "Coverage: $comment_message"
echo "$comment_message" > updated_comment.txt
- name: Post Comment
uses: mshick/add-pr-comment@7c0890544fb33b0bdd2e59467fbacb62e028a096 #v2.8.1
with:
issue: ${{ env.PR_NUMBER }}
message-path: updated_comment.txt