test(action): fastapi docs try out #1
This file contains hidden or 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: Deploy FastAPI Docs to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - feat/fast-api | |
| jobs: | |
| deploy-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install uvicorn | |
| - name: Run FastAPI app in background | |
| run: | | |
| nohup uvicorn api:app --host 0.0.0.0 --port 8000 & | |
| sleep 5 # Give the server time to start | |
| - name: Fetch OpenAPI schema | |
| run: | | |
| curl http://localhost:8000/openapi.json -o openapi.json | |
| - name: Install redoc-cli | |
| run: | | |
| npm install -g redoc-cli | |
| - name: Generate HTML from OpenAPI spec | |
| run: | | |
| redoc-cli bundle openapi.json -o docs/index.html | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs |