Building the documentation with GitHub Actions and publishing it to GitHub Pages is a common use case.
The following example workflow (build & deploy workflow of this repository) shows how to do this.
# Workflow for building and deploying the Sphinx site to GitHub Pages#name:Deploy docs to GH Pageson:# Runs on pushes targeting the default branchpush:branches:["main"]# Allows you to run this workflow manually from the Actions tabworkflow_dispatch:# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pagespermissions:contents:readpages:writeid-token:write# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.concurrency:group:"pages"cancel-in-progress:falseenv:BUILD_TYPE:Releasejobs:cpp-build:name:C++ Build and Testruns-on:ubuntu-lateststeps:-uses:actions/checkout@v5-uses:lukka/get-cmake@latest# Install lcov for coverage support-name:Install lcovrun:sudo apt-get update && sudo apt-get install -y lcov-name:Build C++ Project with Testsworking-directory:srcrun:|# Configure CMake without coverage for CI (coverage can be added later if needed)cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}# Build the projectcmake --build build --config ${{env.BUILD_TYPE}}-name:Run C++ Testsworking-directory:src/buildrun:|# Run tests with XML output./eac_test --gtest_output=xml:test-results.xml-name:Upload Test Resultsuses:actions/upload-artifact@v4with:name:test-resultspath:src/build/test-results.xmlbuild:name:Build Documentationruns-on:ubuntu-latestneeds:cpp-buildsteps:-uses:actions/checkout@v5-name:Setup Pagesid:pagesuses:actions/configure-pages@v5-name:Download Test Resultsuses:actions/download-artifact@v4with:name:test-resultspath:src/build-name:Install System Dependenciesrun:sudo apt-get update && sudo apt-get install -y graphviz plantuml-name:Install uvuses:astral-sh/setup-uv@v5with:enable-cache:true-name:Install Python dependenciesrun:uv sync-name:Build Sphinx Documentationrun:uv run sphinx-build -b html docs docs/_build/html-name:Upload Documentation Artifactuses:actions/upload-pages-artifact@v4with:path:docs/_build/htmldeploy:environment:name:github-pagesurl:${{ steps.deployment.outputs.page_url }}needs:buildruns-on:ubuntu-latestname:Deploysteps:-name:Deploy to GitHub Pagesid:deploymentuses:actions/deploy-pages@v4