name: Update API Documentation on: push: branches: - main paths: - 'api/docs/**' workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true # Add permissions for GITHUB_TOKEN permissions: contents: write pull-requests: write jobs: create-docs-pr: runs-on: ubuntu-latest steps: - name: Checkout source repository uses: actions/checkout@v5 with: path: source-repo - name: Checkout docs repository uses: actions/checkout@v5 with: repository: unraid/docs path: docs-repo token: ${{ secrets.DOCS_PAT_UNRAID_BOT }} - name: Copy and process docs run: | if [ ! -d "source-repo/api/docs" ]; then echo "Source directory does not exist!" exit 1 fi # Remove old API docs but preserve other folders rm -rf docs-repo/docs/API/ mkdir -p docs-repo/docs/API # Copy all markdown files and maintain directory structure cp -r source-repo/api/docs/public/. docs-repo/docs/API/ # Copy images to Docusaurus static directory mkdir -p docs-repo/static/img/api # Copy images from public/images if they exist if [ -d "source-repo/api/docs/public/images" ]; then cp -r source-repo/api/docs/public/images/. docs-repo/static/img/api/ fi # Also copy any images from the parent docs/images directory if [ -d "source-repo/api/docs/images" ]; then cp -r source-repo/api/docs/images/. docs-repo/static/img/api/ fi # Update image paths in markdown files # Replace relative image paths with absolute paths pointing to /img/api/ find docs-repo/docs/API -name "*.md" -type f -exec sed -i 's|!\[\([^]]*\)\](\./images/\([^)]*\))|![\1](/img/api/\2)|g' {} \; find docs-repo/docs/API -name "*.md" -type f -exec sed -i 's|!\[\([^]]*\)\](images/\([^)]*\))|![\1](/img/api/\2)|g' {} \; find docs-repo/docs/API -name "*.md" -type f -exec sed -i 's|!\[\([^]]*\)\](../images/\([^)]*\))|![\1](/img/api/\2)|g' {} \; - name: Create Pull Request uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.DOCS_PAT_UNRAID_BOT }} path: docs-repo commit-message: 'docs: update API documentation' title: 'Update API Documentation' body: | This PR updates the API documentation based on changes from the main repository. Changes were automatically generated from api/docs/* directory. @coderabbitai ignore reviewers: ljm42, elibosley branch: update-api-docs base: main delete-branch: true