Skip to content

Commit fdb8f26

Browse files
committed
ci: deploy code coverage page
1 parent 87a4b82 commit fdb8f26

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version: 1.20
23+
24+
- name: Install dependencies
25+
run: go mod tidy
26+
27+
- name: Run tests and generate coverage report
28+
run: |
29+
go test -coverprofile=coverage.out ./pkg
30+
go tool cover -html=coverage.out -o coverage.html
31+
32+
- name: Upload coverage report
33+
uses: actions/upload-artifact@v2
34+
with:
35+
name: coverage-report
36+
path: coverage.html
37+
38+
deploy:
39+
runs-on: ubuntu-latest
40+
needs: build
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v2
45+
46+
- name: Download coverage report
47+
uses: actions/download-artifact@v2
48+
with:
49+
name: coverage-report
50+
path: ./coverage
51+
52+
- name: Deploy to GitHub Pages
53+
uses: peaceiris/actions-gh-pages@v3
54+
with:
55+
github_token: ${{ secrets.GITHUB_TOKEN }}
56+
publish_dir: ./coverage
57+
publish_branch: gh-pages

0 commit comments

Comments
 (0)