Skip to content

Publish coverage report on gh-pages branch #19

Publish coverage report on gh-pages branch

Publish coverage report on gh-pages branch #19

Workflow file for this run

name: CI/CD
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ^1.23
- name: Install dependencies
run: go get -v -t ./...
- name: Build
run: go build -v ./...
- name: Test with coverage
run: |
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
go tool cover -html=coverage.out -o coverage.html
COVERAGE=$(go tool cover -func=coverage.out | grep total: | grep -Eo '[0-9]+\.[0-9]+')
echo "{\"coverage\": \"${COVERAGE}%\"}" > coverage.json
- name: Deploy coverage to GitHub Pages
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/gh-pages'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .
publish_files: |
coverage.html
coverage.json