name: Build and deploy documentation

# Controls when the workflow will run

on:
  #Enable this trigger to test changes to this workflow via build requests
  #pull_request:

  # Runs the trigger when a git TAG is created:
  push:
    tags:
      - '*'

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-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: false

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # run on tumbleweed
    container:
      image: registry.opensuse.org/opensuse/tumbleweed:latest
      volumes:
        - my_docker_volume:/volume_mount

    # Steps required to build the docs
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install dependencies
        run: bash -c 'zypper in -y "FastCGI-devel"  "cmake >= 3.17"  "dejagnu"  "doxygen"  "gcc-c++ >= 7"  "gettext-devel"  "ghostscript"  "glib2-devel"  "graphviz"  "libboost_headers-devel"  "libboost_program_options-devel"  "libboost_test-devel"  "libboost_thread-devel"  "libbz2-devel"  "libcurl-devel >= 7.19.4"  "libgpgme-devel"  "libproxy-devel"  "libsigc++2-devel"  "libsolv-devel-static >= 0.7.34"  "libsolv-tools-base >= 0.7.29"  "libxml2-devel"  "libzck-devel"  "libzstd-devel"  "nginx"  "pkg-config"  "pkgconfig(libudev)"  "pkgconfig(openssl)"  "readline-devel >= 5.1"  "rpm"  "rpm-devel > 4.4"  "rubygem(asciidoctor)"  "squid"  "texlive-dvips"  "texlive-latex"  "texlive-newunicodechar"  "texlive-xcolor"  "vsftpd"  "xz-devel"  "yaml-cpp-devel" "graphviz-gd"'

      # Build the docs
      - name: Run the build
        run: |
            mkdir build
            cd build
            cmake ..
            make doc

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./build/zypp/doc/autodoc/html

  # Deployment job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
