Skip to content

Commit

Permalink
build html doc in ci and push to gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ringsaturn committed Sep 12, 2022
1 parent e8ace37 commit cc46d8d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 672 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build-pb-doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: build-pb-doc

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: write
deployments: write

jobs:
build-doc:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install go pkgs
run: |
make install
- name: Setup protoc
uses: arduino/[email protected]

- name: Build doc
run: |
make pb
- name: Upload a Build Artifact
uses: actions/[email protected]
if: ${{ github.ref_name == 'main' }}
with:
name: "Probuf HTML File"
path: "pb/index_pb.html"

push-doc:
needs: build-doc
runs-on: ubuntu-latest
if: ${{ github.ref_name == 'main' }}
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages

- name: Download a Build Artifact
uses: actions/[email protected]
with:
name: "Probuf HTML File"
path: "./docs"

- name: Push file update
run: |
git add ./docs/index_pb.html
git config user.name github-actions
git config user.email [email protected]
git commit -m "Update Probuf HTML doc"
git push
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PROTO_FILES=$(shell find pb -name *.proto)
install:
go mod download
go install github.com/mfridman/tparse@latest
go install github.com/golang/protobuf/protoc-gen-go@latest
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest

fmt:
Expand All @@ -12,7 +13,7 @@ fmt:
.PHONY:pb
pb:
protoc --proto_path=. \
--doc_out=. --doc_opt=html,index.html,source_relative \
--doc_out=. --doc_opt=html,index_pb.html,source_relative \
--go_out=paths=source_relative:. \
$(PROTO_FILES)

Expand Down
2 changes: 1 addition & 1 deletion pb/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# TZF's Proto

[Probuf define](https://refined-github-html-preview.kidonng.workers.dev/ringsaturn/tzf/raw/main/pb/index.html)
[Probuf define](https://ringsaturn.github.io/tzf/index_pb.html)
Loading

0 comments on commit cc46d8d

Please sign in to comment.