Generated Docs #44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generated Docs | |
| on: | |
| workflow_run: | |
| workflows: | |
| - CI | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| commit-generated-docs: | |
| if: >- | |
| github.event_name == 'workflow_dispatch' || | |
| ( | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && | |
| github.event.workflow_run.head_branch == 'main' | |
| ) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Refresh branch | |
| run: git pull --ff-only origin main | |
| - name: Set up Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: "3.12" | |
| - name: Install pipx and Poetry | |
| run: | | |
| python -m pip install --upgrade pip pipx | |
| python -m pipx ensurepath | |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | |
| pipx install poetry | |
| - name: Install dependencies | |
| run: poetry install --no-interaction --with dev | |
| - name: Generate docs | |
| run: | | |
| poetry run sync-docs-readme | |
| poetry run generate-cli-docs | |
| poetry run generate-cli-man-docs | |
| poetry run generate-ansible-docs | |
| - name: Check docs | |
| run: | | |
| poetry run check-doc-links | |
| poetry run check-doc-artifacts | |
| - name: Commit generated docs | |
| id: docs | |
| run: | | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| if [ -z "$(git status --porcelain docs/cli docs/man docs/ansible)" ]; then | |
| echo "Generated docs are up to date." | |
| exit 0 | |
| fi | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@users.noreply.cisco.com" | |
| git add docs/cli docs/man docs/ansible | |
| git commit -m "docs: update generated references" | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| - name: Push generated docs | |
| if: steps.docs.outputs.changed == 'true' | |
| env: | |
| SCCFM_CI_DEPLOY_KEY: ${{ secrets.SCCFM_CI_DEPLOY_KEY }} | |
| run: | | |
| set -euo pipefail | |
| SSH_ROOT="$(mktemp -d "${RUNNER_TEMP}/sccfm-docs-ssh.XXXXXX")" | |
| cleanup_ssh() { | |
| rm -rf "${SSH_ROOT}" | |
| } | |
| trap cleanup_ssh EXIT | |
| umask 077 | |
| DEPLOY_KEY_PATH="${SSH_ROOT}/deploy-key" | |
| KNOWN_HOSTS_PATH="${SSH_ROOT}/known-hosts" | |
| test -n "${SCCFM_CI_DEPLOY_KEY}" | |
| printf '%s\n' "${SCCFM_CI_DEPLOY_KEY}" > "${DEPLOY_KEY_PATH}" | |
| chmod 600 "${DEPLOY_KEY_PATH}" | |
| unset SCCFM_CI_DEPLOY_KEY | |
| curl --fail --silent --show-error --location \ | |
| https://api.github.com/meta \ | |
| | jq -er '.ssh_keys[] | "github.com " + .' > "${KNOWN_HOSTS_PATH}" | |
| test -s "${KNOWN_HOSTS_PATH}" | |
| GIT_SSH_COMMAND="ssh -i ${DEPLOY_KEY_PATH} -o IdentitiesOnly=yes -o UserKnownHostsFile=${KNOWN_HOSTS_PATH} -o StrictHostKeyChecking=yes" | |
| PUSH_REMOTE="git@github.com:${GITHUB_REPOSITORY}.git" | |
| GIT_SSH_COMMAND="${GIT_SSH_COMMAND}" git push "${PUSH_REMOTE}" HEAD:main |