diff --git a/.github/workflows/godoc.yml b/.github/workflows/godoc.yml new file mode 100644 index 00000000..dfe92f98 --- /dev/null +++ b/.github/workflows/godoc.yml @@ -0,0 +1,69 @@ +name: godoc +on: + workflow_run: + workflows: + - main + types: + - completed +env: + MOD: github.com/reearth/reearth-backend + REPO: github.com/reearth/reearth-backend + REPO_NAME: reearth-backend + ADDR: 'localhost:8080' +jobs: + godoc: + name: godoc + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + env: + DIR: ${{ github.event.workflow_run.head_branch }} + steps: + - name: set up + uses: actions/setup-go@v2 + with: + go-version: 1.16 + id: go + - name: checkout + uses: actions/checkout@v2 + - name: cache + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - run: go mod download + - name: install godoc + run: go install golang.org/x/tools/cmd/godoc@latest + - name: generate docs + continue-on-error: true + run: | + godoc -http="$ADDR" & + sleep 10 + wget -r -np -N -E -p -k "http://${ADDR}/pkg/${MOD}/" + - name: replace urls + run: | + [ `find . -name "*.html" -type f | wc -l` -eq 0 ] && exit 1 + find ./${ADDR}/ -name "*.html" -print0 | xargs -0 sed -i \ + -e "s@http://${ADDR}/src/${MOD}@https://${REPO}/blob/main@" \ + -e "s@\"http://${ADDR}/pkg/\"@\"/${REPO_NAME}/${DIR}/pkg/${REPO}/\"@" \ + -e 's@