Skip to content

Swagger, Redoc & logger viewer deployment #17

@umar-anzar

Description

@umar-anzar
name: Deploy to GitHub Pages

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    # Checkout the code
    - name: Checkout
      uses: actions/checkout@v3

    # Install Python and dependencies
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: 3.9

    - name: Install dependencies
      run: pip install -r requirements.txt

    # Run the FastAPI server in the background
    - name: Start FastAPI server
      run: nohup uvicorn main:app --host 0.0.0.0 --port 8000 &

    # Wait for server to start
    - name: Wait for server
      run: sleep 5

    # Fetch the HTML pages
    - name: Save /docs page
      run: curl http://127.0.0.1:8000/docs -o docs.html

    - name: Save /redoc page
      run: curl http://127.0.0.1:8000/redoc -o redoc.html

    - name: Save /logger-viewer page
      run: curl http://127.0.0.1:8000/logger-viewer -o logger-viewer.html

    # Stop the server
    - name: Stop FastAPI server
      run: pkill uvicorn

    # Create a folder for GitHub Pages
    - name: Prepare GitHub Pages
      run: mkdir -p gh-pages

    - name: Move HTML files
      run: mv *.html gh-pages/

    # Deploy to GitHub Pages
    - name: Deploy to GitHub Pages
      uses: peaceiris/actions-gh-pages@v3
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: gh-pages
        publish_branch: gh-pages

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions