diff --git a/.github/workflows/generate-pdf.yml b/.github/workflows/generate-pdf.yml new file mode 100644 index 0000000..052b9a3 --- /dev/null +++ b/.github/workflows/generate-pdf.yml @@ -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 diff --git a/.sage/main.go b/.sage/main.go index fdaa80d..8cd8782 100644 --- a/.sage/main.go +++ b/.sage/main.go @@ -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() +} diff --git a/Makefile b/Makefile index 50b632c..f2ad53b 100644 --- a/Makefile +++ b/Makefile @@ -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