⚙️ GitHub Action: Generate Playbook Docs

📖 Purpose

This workflow ensures that documentation for all Ansible roles is automatically generated and kept up to date. Whenever code is pushed or a pull request is opened, the workflow runs the Generate Playbook Documentation Script script, which regenerates per‑playbook markdown files, builds folder‑level summaries, maintains a global index of playbooks, and commits the changes back to the repository.

🛠 Workflow File

Located at: .github/workflows/generate-playbook-docs.yml

name: Generate Ansible Playbook Docs

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  generate-playbook-docs:
    # Only run the job logic when the branch is main
    if: github.ref == 'refs/heads/main'
    
    runs-on: ubuntu-latest

    steps:
      # Checkout the repo
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0  # needed for committing back

      # Set up Python
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      # Install dependencies (if any)
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt

      # Run the documentation generator
      - name: Generate playbook docs
        run: |
          python ./scripts/generate_playbook_docs.py

      - name: Commit and push changes
        run: |
          git config --global user.name "github-actions[bot]"
          git config --global user.email "github-actions[bot]@users.noreply.github.com"
          git pull origin main
          git add playbooks/README.md docs/playbooks/README.md docs/playbooks/*.md

          if ! git diff --cached --quiet; then
            git commit -m "chore(docs): auto-generate playbook documentation"
            git push origin main
          else
            echo "No documentation changes to commit."
          fi

🔹 Workflow Details

Trigger

Jobs

generate-inventory-docs


📝 Summary