Skip to content

Commit

Permalink
ci: genrate api documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
thall committed Jul 17, 2023
1 parent 8491b5e commit 3f6035e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/generate-pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: generate-api-documentation

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
make:
runs-on: ubuntu-latest
steps:
- name: Setup Sage
uses: einride/sage/actions/setup@master
with:
go-version: 1.19

- name: Setup Node
# Latest version `v3.7.0` contains a bug, see the following issue:
# https://github.com/actions/setup-node/issues/801
uses: actions/setup-node@v3.6.0
with:
node-version: 18
#registry-url: https://registry.npmjs.org
#cache: "yarn"
#cache-dependency-path: frontend/yarn.lock

- name: Generate PDF's
run: make generate-pdf

- uses: actions/upload-artifact@v3
with:
name: auth-pdf
path: auth.pdf
15 changes: 15 additions & 0 deletions .sage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,18 @@ func ServePDF(ctx context.Context) error {
Handler: httpMux,
}).ListenAndServe()
}

func GeneratePDF(ctx context.Context) error {
sg.SerialDeps(ctx, installRapiPDFCLI, generateAuthPDF)
return nil
}

func installRapiPDFCLI(ctx context.Context) error {
cmd := sg.Command(ctx, "npm", "install", "@kingjan1999/rapipdf-cli")
return cmd.Run()
}

func generateAuthPDF(ctx context.Context) error {
cmd := sg.Command(ctx, "npm", "rapipdf", "--outputFile=auth.pdf", "openapiv2/auth.swagger.yaml")
return cmd.Run()
}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ format-markdown: $(sagefile)
format-yaml: $(sagefile)
@$(sagefile) FormatYaml

.PHONY: generate-pdf
generate-pdf: $(sagefile)
@$(sagefile) GeneratePDF

.PHONY: git-verify-no-diff
git-verify-no-diff: $(sagefile)
@$(sagefile) GitVerifyNoDiff
Expand Down

0 comments on commit 3f6035e

Please sign in to comment.