Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: deploy api.bytebase.com to Cloudflare Pages (#21456)
Tianzhou92d232bc1593
diff --git a/.github/workflows/deploy-api-docs.yml b/.github/workflows/deploy-api-docs.ymlnew file mode 100644index 0000000000..2139457aea--- /dev/null+++ b/.github/workflows/deploy-api-docs.yml@@ -0,0 +1,48 @@+name: Deploy API docs to Cloudflare Pages++on:+ push:+ branches: [main]+ paths:+ - 'proto/gen/grpc-doc/openapi.yaml'+ - 'docs/api/**'+ - '.github/workflows/deploy-api-docs.yml'+ workflow_dispatch:++permissions:+ contents: read+ deployments: write++jobs:+ deploy:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v7++ - uses: actions/setup-node@v4+ with:+ node-version: 22++ # The buf plugin emits a placeholder info block; give the published spec a real title.+ - name: Assemble site+ run: |+ mkdir -p out+ cp docs/api/index.html docs/api/favicon.png out/+ sed -e '1,5s/^ title: API$/ title: Bytebase API Reference/' \+ -e '1,5s/^ description: API documentation for API$/ description: API reference for Bytebase. Every endpoint is served by your own Bytebase instance./' \+ proto/gen/grpc-doc/openapi.yaml > out/openapi.yaml+ head -5 out/openapi.yaml++ # Create the Pages project on first run; a no-op once it exists.+ - name: Ensure Cloudflare Pages project exists+ env:+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}+ run: npx --yes wrangler@3 pages project create bytebase-api --production-branch=main || true++ - name: Deploy to Cloudflare Pages+ uses: cloudflare/wrangler-action@v3+ with:+ apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}+ accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}+ command: pages deploy ./out --project-name=bytebase-apidiff --git a/docs/api/README.md b/docs/api/README.mdindex 2b78a38b64..4c45b775eb 100644--- a/docs/api/README.md+++ b/docs/api/README.md@@ -1 +1,15 @@-The public assets of <https://api.bytebase.com>+# api.bytebase.com++Static [Scalar](https://scalar.com/) site for the OpenAPI spec generated at+`proto/gen/grpc-doc/openapi.yaml`.++`.github/workflows/deploy-api-docs.yml` copies this directory plus the spec into+`out/` and deploys it to the Cloudflare Pages project `bytebase-api` on every+push to `main` that touches either. The custom domain is attached in the+Cloudflare dashboard.++Preview locally:++```bash+mkdir -p /tmp/api-docs && cp docs/api/* proto/gen/grpc-doc/openapi.yaml /tmp/api-docs && python3 -m http.server -d /tmp/api-docs 8080+```diff --git a/docs/api/index.html b/docs/api/index.htmlindex 42047d3e83..8ecfeada15 100644--- a/docs/api/index.html+++ b/docs/api/index.html@@ -1,33 +1,27 @@<!doctype html>-<html>+<html lang="en"><head><title>Bytebase API Reference</title>- <link rel="icon" href="favicon.png" type="image/x-icon">+ <link rel="icon" href="favicon.png" type="image/png"><meta charset="utf-8" />- <meta- name="viewport"- content="width=device-width, initial-scale=1" />+ <meta name="viewport" content="width=device-width, initial-scale=1" /></head><body>- <script- id="api-reference"- data-url="https://raw.githubusercontent.com/bytebase/bytebase/main/proto/gen/grpc-doc/openapi.yaml"></script>+ <div id="app"></div>+ <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script><script>- var configuration = {+ Scalar.createApiReference('#app', {+ url: './openapi.yaml',theme: 'moon',metaData: {- title: 'Bytebase API Reference',- description: 'Bytebase API Reference',- ogDescription: 'Bytebase API Reference',- ogTitle: 'Bytebase API Reference',- ogImage: 'https://raw.githubusercontent.com/bytebase/bytebase/main/docs/assets/banner.jpg',- twitterCard: 'summary_large_image',- }- }-- var apiReference = document.getElementById('api-reference')- apiReference.dataset.configuration = JSON.stringify(configuration)+ title: 'Bytebase API Reference',+ description: 'Bytebase API Reference',+ ogDescription: 'Bytebase API Reference',+ ogTitle: 'Bytebase API Reference',+ ogImage: 'https://raw.githubusercontent.com/bytebase/bytebase/main/docs/assets/banner.jpg',+ twitterCard: 'summary_large_image',+ },+ })</script>- <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script></body>-</html>\ No newline at end of file+</html>