Skip to content

Commit

Permalink
feat: keep public and private API docs in sync with main branch
Browse files Browse the repository at this point in the history
⚠️ This is a WIP commit. I created a playground environment to test the
GitHub actions. The workflow file has been copied from
https://github.com/jvallesm/instill-protobufs and references API IDs
that don't belong to the Instill AI organisation.

We should update the API doc IDs and introduce a `README_API_KEY`
repository variable.

- Changes in main branch update the staging docs
- Version changes in main branch update the public docs
  • Loading branch information
jvallesm committed Feb 13, 2024
1 parent 15d3669 commit 46435e0
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/sync-api-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Sync docs in ReadMe 🦉

on:
push:
branches:
# This workflow will run every time changes in the OpenAPI docs are
# pushed to the `main` branch.
- main
paths:
- 'openapiv2/core/**'
- 'openapiv2/model/**'
- 'openapiv2/vdp/**'

jobs:
sync-openapi-private:
name: Keep private (staging) docs in sync with `main`
runs-on: ubuntu-latest
outputs:
shouldUpdatePublic: ${{ steps.checkNewRelease.outputs.isNewRelease }}
steps:
- name: Check out repo 📚
uses: actions/checkout@v3

- name: Sync Core 🔮
uses: readmeio/rdme@v8
with:
rdme: openapi openapiv2/core/service.swagger.yaml --key=${{ secrets.README_API_KEY }} --id=65ca17433dcd850078ffca3f

- name: Sync Model ⚗️
uses: readmeio/rdme@v8
with:
rdme: openapi openapiv2/model/service.swagger.yaml --key=${{ secrets.README_API_KEY }} --id=65ca17433dcd850078ffca41

- name: Sync VDP 💧
uses: readmeio/rdme@v8
with:
rdme: openapi openapiv2/vdp/service.swagger.yaml --key=${{ secrets.README_API_KEY }} --id=65ca17433dcd850078ffca40

- name: Check new release
id: checkNewRelease
run: |
if [[git diff HEAD~ openapiv2/vdp openapiv2/core openapiv2/model | grep "^+\s\+version"]]; then
echo "::set-output name=isNewRelease::true"
else
echo "::set-output name=isNewRelease::false"
fi
sync-openapi-public:
name: Sync public docs on new release
needs: [sync-openapi-private]
runs-on: ubuntu-latest
if: needs.sync-openapi-private.outputs.shouldUpdatePublic == 'true'
steps:
- name: Check out repo 📚
uses: actions/checkout@v3

- name: Sync Core 🔮
uses: readmeio/rdme@v8
with:
rdme: openapi openapiv2/core/service.swagger.yaml --key=${{ secrets.README_API_KEY }} --id=659fcafc3ca8be005651d43f

- name: Sync Model ⚗️
uses: readmeio/rdme@v8
with:
rdme: openapi openapiv2/model/service.swagger.yaml --key=${{ secrets.README_API_KEY }} --id=65a6a52ab94959005b83f6fc

- name: Sync VDP 💧
uses: readmeio/rdme@v8
with:
rdme: openapi openapiv2/vdp/service.swagger.yaml --key=${{ secrets.README_API_KEY }} --id=65a15372e7857a001655767c

0 comments on commit 46435e0

Please sign in to comment.