name: Documentation on: push: branches: - master tags: - '*' # Publishing commits to the gh-pages branch, so only run when something that # affects the documentation actually changed. Use the manual "Run workflow" # button if a deploy is needed outside of these paths. paths: &docs_paths - '.github/workflows/docs.yml' - 'CMakeLists.txt' - 'Doxyfile.in' - 'docs-report.sh' - 'website/**' - 'doxygen/**' - 'package.xml' - 'corelib/include/**' - 'utilite/include/**' pull_request: branches: - '**' paths: *docs_paths workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: contents: read jobs: build: name: Build site (ubuntu-24.04) runs-on: ubuntu-24.04 outputs: version: ${{ steps.site.outputs.version }} steps: - uses: actions/checkout@v4 - name: Install dependencies run: | DEBIAN_FRONTEND=noninteractive sudo apt-get update sudo apt-get install -y \ doxygen \ graphviz \ cmake \ libopencv-dev \ libpcl-dev \ libyaml-cpp-dev \ git # Configures build-docs (CMake generates the export headers that are part # of Doxygen's INPUT), runs Doxygen into build-docs/api/latest/. Same # script used locally, so a local preview matches what gets published. - name: Generate C++ API documentation (Doxygen) run: ./docs-report.sh # The theme emits absolute asset links built from site.baseurl, which # GitHub's own Jekyll infers from the repository (/rtabmap). A PR preview # is served from a deeper path, so those links would 404 there. Pin # baseurl to the path this particular build gets published to. - name: Set Jekyll baseurl run: | set -eux if [ "${{ github.event_name }}" = "pull_request" ]; then baseurl="/${{ github.event.repository.name }}/preview/pr-${{ github.event.number }}" else baseurl="/${{ github.event.repository.name }}" fi echo "baseurl: ${baseurl}" >> website/_config.yml # Landing page: built here rather than by GitHub's own Jekyll, so that # .nojekyll can be set below and the Doxygen output is served untouched. - name: Build landing page (Jekyll) uses: actions/jekyll-build-pages@v1 with: source: ./website destination: ./_site - name: Assemble site id: site run: | set -eux # jekyll-build-pages is a container action running as root, so _site # comes back owned by root and the steps below (running as the runner # user) cannot write into it. sudo chown -R "$(id -u):$(id -g)" _site # Serve everything verbatim: the site is already built, and Jekyll # would otherwise skip Doxygen files/folders starting with '_'. touch _site/.nojekyll mkdir -p _site/api cp -r build-docs/api/latest _site/api/latest # On a release tag (plain X.Y.Z, not the ROS-distro variants such as # 0.23.7-jazzy), also publish under the version number. Older versions # already on the branch are preserved by keep_files when publishing. version="" if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then version="${GITHUB_REF_NAME}" cp -r build-docs/api/latest "_site/api/${version}" fi echo "version=${version}" >> "$GITHUB_OUTPUT" # The dropdown list is maintained by hand in the repository (one entry # per release) and shared by every published version -- see the header # comment in doxygen/versions.js. cp doxygen/versions.js _site/api/versions.js # /api/ has no content of its own: send it to the current docs so a # bare .../api/ link lands somewhere useful instead of a 404. The # target is relative, so it works at the site root and under a # preview prefix alike. printf '%s\n' \ '' \ '' \ '
Redirecting to the latest API documentation.
' \ > _site/api/index.html test -f _site/index.html test -f _site/api/index.html test -f _site/api/latest/index.html - name: Upload site artifact uses: actions/upload-artifact@v4 with: name: documentation-site path: _site # include-hidden-files keeps .nojekyll, which the publish job needs. include-hidden-files: true retention-days: 14 publish: name: Publish to gh-pages needs: build # Forks are skipped for pull requests: their GITHUB_TOKEN is read-only, and # granting write access to a workflow that builds untrusted code would be a # security hole. if: >- github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-24.04 # Serialize every push to gh-pages, including the preview cleanup workflow, # and never cancel one in flight: two concurrent pushes would collide. concurrency: group: gh-pages-publish cancel-in-progress: false permissions: contents: write steps: - name: Download site uses: actions/download-artifact@v4 with: name: documentation-site path: _site # Pull requests go to preview/pr-