|
| 1 | +name: Sync Documentation Code Blocks |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run daily at 2 AM UTC to catch any changes |
| 6 | + - cron: '0 2 * * *' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + agent_sdk_ref: |
| 10 | + description: 'Agent SDK branch/tag/commit to sync from' |
| 11 | + required: false |
| 12 | + default: 'main' |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + pull-requests: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + sync-code-blocks: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + if: github.actor != 'github-actions[bot]' |
| 22 | + steps: |
| 23 | + - name: Checkout docs repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + |
| 28 | + - name: Checkout agent-sdk |
| 29 | + uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + repository: OpenHands/software-agent-sdk |
| 32 | + path: agent-sdk |
| 33 | + ref: ${{ github.event.inputs.agent_sdk_ref || 'main' }} |
| 34 | + fetch-depth: 0 |
| 35 | + |
| 36 | + - name: Set up Python |
| 37 | + uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: '3.11' |
| 40 | + |
| 41 | + - name: Install dependencies for API docs |
| 42 | + run: | |
| 43 | + python -m pip install --upgrade pip |
| 44 | + pip install sphinx sphinx-markdown-builder myst-parser |
| 45 | +
|
| 46 | + - name: Sync code blocks |
| 47 | + env: |
| 48 | + AGENT_SDK_PATH: ${{ github.workspace }}/agent-sdk |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + set -euo pipefail |
| 52 | + python .github/scripts/sync_code_blocks.py |
| 53 | +
|
| 54 | + - name: Generate API documentation |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + set -euo pipefail |
| 58 | + python scripts/generate-api-docs.py |
| 59 | +
|
| 60 | + - name: Check for changes |
| 61 | + id: detect_changes |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + set -euo pipefail |
| 65 | + if [[ -n "$(git status --porcelain)" ]]; then |
| 66 | + echo "changes=true" >> "$GITHUB_OUTPUT" |
| 67 | + else |
| 68 | + echo "changes=false" >> "$GITHUB_OUTPUT" |
| 69 | + fi |
| 70 | +
|
| 71 | + - name: Create Pull Request |
| 72 | + if: steps.detect_changes.outputs.changes == 'true' |
| 73 | + uses: peter-evans/create-pull-request@v7 |
| 74 | + with: |
| 75 | + commit-message: | |
| 76 | + docs: sync code blocks and generate API reference |
| 77 | +
|
| 78 | + Synced from agent-sdk ref: ${{ github.event.inputs.agent_sdk_ref || 'main' }} |
| 79 | + branch: sync-docs-and-api |
| 80 | + branch-suffix: timestamp |
| 81 | + delete-branch: true |
| 82 | + title: "docs: sync code blocks and generate API reference" |
| 83 | + body: | |
| 84 | + ## Summary of changes |
| 85 | +
|
| 86 | + This PR automatically syncs code blocks in documentation with their corresponding source files from the agent-sdk repository, and generates API reference documentation. |
| 87 | +
|
| 88 | + **Agent SDK Reference**: `${{ github.event.inputs.agent_sdk_ref || 'main' }}` |
| 89 | +
|
| 90 | + ### Changes Made |
| 91 | + - Updated code blocks in MDX files to match the current state of example files in agent-sdk |
| 92 | + - Generated API reference markdown files |
| 93 | + - This is an automated sync performed by the `sync-docs-code-blocks` workflow |
| 94 | +
|
| 95 | + ### Checklist |
| 96 | + - [x] I have read and reviewed the documentation changes to the best of my ability. |
| 97 | + - [x] If the change is significant, I have run the documentation site locally and confirmed it renders as expected. |
0 commit comments