-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (43 loc) · 1.7 KB
/
post_release.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
name: Post Release
'on':
push:
branches:
- master
paths:
- 'contracts/**'
- 'test/**'
workflow_dispatch: null
jobs:
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- name: "⏬ Checkout repository"
uses: actions/checkout@v3
- name: "\U0001F530 Setup Node"
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: npm
- name: "\U0001F4E6 Install dependencies"
run: npm install
- name: "\U0001F9EA Test and Coverage"
run: npm run coverage
- name: "\U0001F4D1 Extract total coverage percentage"
run: |
coverage_percentage=$(cat ./coverage/index.html | \
grep -o 'class="strong">[0-9]*% ' | \
sed 's/class="strong">//g' | \
awk '{ sum += int($1); count++ } END { if (count > 0) { print sum/count } else { print 0 } }')
echo "coverage_percentage=$coverage_percentage" >> "$GITHUB_ENV"
shell: bash
- name: "📝 Write percentage to README"
# In README, replace the line between <!--START_SECTION:coverage--> and <!--END_SECTION:coverage--> with the coverage percentage badge, keeping the rest of the file intact.
run: |
sed -i '/<!--START_SECTION:coverage-->/, /<!--END_SECTION:coverage-->/c\<!--START_SECTION:coverage-->\n\n<!--END_SECTION:coverage-->' README.md
- name: "✅ Commit and push changes"
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "docs: Update coverage percentage on README.md"
push_options: "--force"
file_pattern: "*.md"