diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml new file mode 100644 index 0000000..51a131e --- /dev/null +++ b/.github/workflows/generate-docs.yml @@ -0,0 +1,67 @@ +name: Generate Documentation +on: + push: + branches: + - master + - auto-docs + workflow_dispatch: +jobs: + build-docs: + runs-on: ubuntu-latest + steps: + - name: Checkout source repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: install dependencies required by glfw/mujoco + run: | + sudo apt-get update + sudo apt-get install -y libosmesa6-dev libgl1 libglu1-mesa freeglut3-dev + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install PyOpenGL PyOpenGL-accelerate + pip install -e . + pip install pdoc black loguru ks_digital_twin + - name: Generate documentation + run: | + export MUJOCO_GL=osmesa + export PYTHONPATH=$PYTHONPATH:$(pwd) + export PDOC_ALLOW_EXEC=1 + pdoc --output-dir ./docs kos_sim + env: + MUJOCO_GL: osmesa + PDOC_ALLOW_EXEC: 1 + - name: Setup GitHub CLI + run: | + gh auth setup-git + gh auth status + env: + GH_TOKEN: ${{ secrets.API_DOCS_TOKEN }} + - name: Checkout api-docs repository + uses: actions/checkout@v4 + with: + repository: kscalelabs/api-docs + path: api-docs + token: ${{ secrets.API_DOCS_TOKEN }} + - name: Copy documentation to api-docs + run: | + mkdir -p api-docs/kos_sim + cp -r docs/kos_sim/* api-docs/kos_sim/ + - name: Push directly to master branch + run: | + cd api-docs + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + # Add and commit changes + git add . + git commit -m "Update documentation from ${{ github.sha }}" || { echo "No changes to commit"; exit 0; } + # Push to the repository with token authentication + git remote set-url origin "https://x-access-token:${{ secrets.API_DOCS_TOKEN }}@github.com/kscalelabs/api-docs.git" + git push origin master + env: + GH_TOKEN: ${{ secrets.API_DOCS_TOKEN }}