auto-update-docs.ymlβ’3.11 kB
name: Update Documentation
on:
workflow_call: {}
workflow_dispatch: {} # Manual trigger for testing
concurrency:
group: update-docs
cancel-in-progress: true
jobs:
update-docs:
name: Update ${{ matrix.manager }} docs
# Restrict to home repository and main branch only for security
if: github.repository == 'KemingHe/python-dependency-manager-companion-mcp-server' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write # Required: commit documentation updates
strategy:
max-parallel: 1 # Prevent commit conflicts
matrix:
include:
- manager: pip
repo: pypa/pip
docs_path: docs
target_dir: src/assets/pip
- manager: conda
repo: conda/conda
docs_path: docs
target_dir: src/assets/conda
- manager: poetry
repo: python-poetry/poetry
docs_path: docs
target_dir: src/assets/poetry
- manager: uv
repo: astral-sh/uv
docs_path: docs
target_dir: src/assets/uv
- manager: pixi
repo: prefix-dev/pixi
docs_path: docs
target_dir: src/assets/pixi
- manager: pdm
repo: pdm-project/pdm
docs_path: docs
target_dir: src/assets/pdm
steps:
- name: Checkout main repo
uses: actions/checkout@v4
- name: Checkout ${{ matrix.manager }} docs
uses: actions/checkout@v4
with:
repository: ${{ matrix.repo }}
sparse-checkout: |
${{ matrix.docs_path }}
path: temp-docs
- name: Copy documentation files
run: |
# Create target directory if not exist
mkdir -p ${{ matrix.target_dir }}
# Copy docs and preserve structure with metadata
cp -a temp-docs/${{ matrix.docs_path }}/* ${{ matrix.target_dir }}/
# Add metadata file with source info
cat > ${{ matrix.target_dir }}/_metadata.json << EOF
{
"source_repo": "${{ matrix.repo }}",
"docs_path": "${{ matrix.docs_path }}",
"updated_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"commit_sha": "$(cd temp-docs && git rev-parse HEAD)"
}
EOF
- name: Clean non-documentation files
run: ./scripts/clean-assets.sh
shell: bash {0} # Avoid double -e flag since script already has -euo pipefail
- name: Pull latest changes by previous update-docs job
run: git pull origin main
- name: Auto commit changes to main
# Pin 3rd-party action to v6.0.1 commit hash released on 2025-06-11 to prevent supply chain attacks
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0
with:
commit_message: 'docs(src/assets/): update ${{ matrix.manager }} official documentation'
file_pattern: 'src/assets/${{ matrix.manager }}/*'