Update OpenAPI spec (#184) #90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "[Rust & Go SDK] Documentation Generator" | |
on: | |
push: | |
branches: [master] | |
paths: | |
- openapi.yaml | |
- 'rust/**' | |
- 'go/**' | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: deploy | |
cancel-in-progress: false | |
jobs: | |
build_docs: | |
name: "[Rust & Go SDK] Generate Docs" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Prepare environment | |
run: | | |
mkdir $RUNNER_TEMP/docs | |
touch $RUNNER_TEMP/docs/index.html | |
mkdir $RUNNER_TEMP/docs/rust | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.18' # Update this with your desired Go version | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install Protoc # This is required for build.rs | |
uses: arduino/setup-protoc@v3 | |
with: | |
version: "26.1" | |
- uses: Swatinem/rust-cache@v2 | |
- uses: actions/configure-pages@v4 | |
id: pages | |
- name: Generate Rust docs | |
working-directory: rust | |
run: | | |
cargo clean --doc | |
cargo doc --no-deps --target-dir=$RUNNER_TEMP/rust | |
cp -r $RUNNER_TEMP/rust/doc/** $RUNNER_TEMP/docs/rust | |
- name: Install doc2go | |
run: go install go.abhg.dev/doc2go@latest | |
- name: Generate Go Docs | |
run: | | |
doc2go -out $RUNNER_TEMP/docs/go ./... | |
- name: Generate OpenAPI Spec | |
run: | | |
npx @redocly/cli build-docs openapi.yaml -o $RUNNER_TEMP/docs/openapi.html | |
- name: Generate index.html | |
run: | | |
cat <<EOT>> $RUNNER_TEMP/docs/index.html | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Coralogix API Documentation</title> | |
</head> | |
<body> | |
<h1>SDK Documentation</h1> | |
<p>Welcome to the documentation for the Coralogix APIs!</p> | |
<ul> | |
<li><a href="rust/cx_sdk/index.html">Rust SDK Documentation</a></li> | |
<li><a href="go/github.com/coralogix/coralogix-management-sdk/go/index.html">Go SDK Documentation</a></li> | |
<li><a href="openapi.html">OpenAPI Spec</a></li> | |
</ul> | |
</body> | |
</html> | |
EOT | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ${{ runner.temp }}/docs | |
deploy: | |
name: "[Docs] Deploy Docs To GitHub Pages" | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: [build_docs] | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |