-
-
Notifications
You must be signed in to change notification settings - Fork 53
66 lines (66 loc) · 2.79 KB
/
GitHub Pages.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
name: GitHub Pages
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'Sources/Towel/**'
- 'Tools/docfx_project/**'
- 'Tools/Towel_Testing/**'
jobs:
documentation:
if: ${{ github.repository == 'ZacharyPatten/Towel' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: dotnet test
run: dotnet test --collect:"XPlat Code Coverage" /nowarn:cs1030
- name: find coverage.cobertura.xml path
run: find . -print | grep -i 'coverage.cobertura.xml' > COVERAGEPATH.txt
- name: move coverage.cobertura.xml file
run: |
COVERAGEPATH=$(<COVERAGEPATH.txt)
mv $COVERAGEPATH coverage.cobertura.xml
- name: dotnet tool install reportgenerator
run: dotnet tool install -g dotnet-reportgenerator-globaltool --version 4.8.11
- uses: nikeee/[email protected]
name: docfx
with:
args: Tools/docfx_project/docfx.json
- name: chmod
run: sudo chmod -R 777 Tools/docfx_project/_site
- name: docfx bug workaround
run: |
sed -i -r 's/api\/[A-Za-z ]+\.[A-Za-z]+/api\/index\.html/' Tools/docfx_project/_site/toc.html
sed -i -r 's/name=""/name="api\/toc\.html"/' Tools/docfx_project/_site/toc.html
- name: make coverage report directory
run: mkdir Tools/docfx_project/_site/coveragereport
- name: generate coverage report
run: reportgenerator "-reports:coverage.cobertura.xml" "-targetdir:Tools/docfx_project/_site/coveragereport" -reporttypes:Html
- name: coverage.xml
run: |
grep -o -E -m 1 'line-rate=\"[.0-9]+\"' coverage.cobertura.xml | head -1 > line-rate.txt
grep -o -E -m 1 '[.0-9]{1,6}' line-rate.txt | head -1 > line-rate2.txt
LINERATE=$(<line-rate2.txt)
echo "$LINERATE * 100" | bc > line-percentage.txt
grep -o -E -m 1 '[0-9]+.[0-9]{0,2}' line-percentage.txt | head -1 > line-percentage2.txt
LINEPERCENTAGE=$(<line-percentage2.txt)
echo '<?xml version="1.0" encoding="utf-8"?>' > coverage.xml
echo '<coverage line-rate-percentage="'$LINEPERCENTAGE'%" />' >> coverage.xml
- name: move coverage.xml
run: mv coverage.xml Tools/docfx_project/_site/coveragereport/coverage.xml
- name: deploy to github-pages branch
run: |
cd Tools/docfx_project/_site
echo "* @ZacharyPatten" > CODEOWNERS
git init --initial-branch=github-pages
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m 'deploy to github-pages branch'
git push --force "https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" github-pages:github-pages