|
| 1 | +--- |
| 2 | +# SPDX-FileCopyrightText: (C) 2025 Intel Corporation |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +name: 'Build Documentation' |
| 6 | + |
| 7 | +on: # yamllint disable-line rule:truthy rule:line-length |
| 8 | + workflow_call: |
| 9 | + inputs: |
| 10 | + docs_directory: |
| 11 | + description: >- |
| 12 | + Documentation directory where the job will run, defaults to '.' |
| 13 | + required: false |
| 14 | + default: "." |
| 15 | + type: string |
| 16 | + simple_mode: |
| 17 | + description: >- |
| 18 | + When true, override configuration for simple documentation sites |
| 19 | + required: false |
| 20 | + default: true |
| 21 | + type: boolean |
| 22 | + exclude_patterns: |
| 23 | + description: >- |
| 24 | + Comma separated list of exclude patterns to use during the build, |
| 25 | + defaults to empty list |
| 26 | + required: false |
| 27 | + default: "" |
| 28 | + type: string |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: read |
| 32 | + |
| 33 | +jobs: |
| 34 | + build-documentation: |
| 35 | + permissions: |
| 36 | + contents: read # minimal privilege required |
| 37 | + runs-on: ubuntu-latest |
| 38 | + env: |
| 39 | + DOCS_DIR: ${{ inputs.docs_directory }} |
| 40 | + steps: |
| 41 | + |
| 42 | + - name: Checkout code |
| 43 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 44 | + with: |
| 45 | + # Fetch all history, otherwise sporadic issue with missing tags |
| 46 | + fetch-depth: 0 |
| 47 | + # Fetch tags |
| 48 | + fetch-tags: true |
| 49 | + # Checkout the branch that triggered the workflow |
| 50 | + # to avoid detached HEAD |
| 51 | + ref: ${{ github.head_ref }} |
| 52 | + persist-credentials: false |
| 53 | + |
| 54 | + - name: Download template |
| 55 | + if: ${{ inputs.simple_mode }} |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + cd "${GITHUB_WORKSPACE}/${DOCS_DIR}" |
| 59 | + wget https://docs.openedgeplatform.intel.com/template/template.tar.gz |
| 60 | + # Override any existing files with template |
| 61 | + tar xf template.tar.gz |
| 62 | + if [ -f "dictionary_append.txt" ]; then |
| 63 | + cat "dictionary_append.txt" >> "dict.txt" |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Add exclude patterns |
| 67 | + env: |
| 68 | + EXCLUDE: ${{ inputs.exclude_patterns }} |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + # Remove any spaces |
| 72 | + exclude_no_spaces="${EXCLUDE// /}" |
| 73 | + # Surround patterns with quotes and create Python list |
| 74 | + exclude_pattern="[\"${exclude_no_spaces//,/\", \"}\"]" |
| 75 | + conf_files=$(find "${GITHUB_WORKSPACE}" -type f -path "*/docs/conf.py") |
| 76 | + for conf_file in $conf_files; do |
| 77 | + echo "exclude_patterns.extend(${exclude_pattern})" >> "$conf_file" |
| 78 | + done |
| 79 | +
|
| 80 | + - name: Build Documentation |
| 81 | + env: |
| 82 | + SIMPLE_MODE: ${{ inputs.simple_mode }} |
| 83 | + shell: bash |
| 84 | + run: | |
| 85 | + cd "${GITHUB_WORKSPACE}/${DOCS_DIR}" |
| 86 | + make build |
0 commit comments