feat: add custom index file #5
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: Build and Deploy MkDocs Versions with Mike | |
| on: | |
| push: | |
| branches: | |
| - 'cells-v4' # Trigger on push to cells-v4 in pydio/docs | |
| - 'cells-v5' | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the docs-source repository (pydio/docs, current branch) | |
| - name: Checkout pydio/docs | |
| uses: actions/checkout@v4 | |
| with: | |
| path: docs-source | |
| # Debug workflow trigger | |
| - name: Debug workflow trigger | |
| run: | | |
| echo "Event: ${{ github.event_name }}" | |
| echo "Branch: ${{ github.ref_name }}" | |
| echo "Repository: ${{ github.repository }}" | |
| # Debug docs-source contents | |
| - name: Debug docs-source contents | |
| run: | | |
| ls -la docs-source/ | |
| # Checkout the mkdocs repository (pydio/mkdocs) | |
| - name: Checkout pydio/mkdocs | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: pydio/mkdocs # Replace with your actual mkdocs repo | |
| path: mkdocs | |
| token: ${{ secrets.MKDOCS_TOKEN }} # Token for write access | |
| # Pull latest gh-pages changes | |
| - name: Pull gh-pages changes | |
| working-directory: mkdocs | |
| run: | | |
| git config user.name "GitHub Action" | |
| git config user.email "[email protected]" | |
| git fetch origin gh-pages | |
| git pull origin gh-pages --rebase || echo "Merge conflicts detected, continuing with local changes" | |
| git status | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.MKDOCS_TOKEN }} | |
| # Set up Python | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| # Cache pip dependencies | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| # Install MkDocs, mike, and dependencies | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install mkdocs mkdocs-material mike mkdocs-redirects mkdocs-minify-plugin pymdown-extensions mkdocs-glightbox git+https://github.com/pydio/mkdocs-awesome-nav | |
| # Get the branch name for versioning | |
| - name: Get branch name | |
| id: branch | |
| run: echo "branch_name=$(echo ${GITHUB_REF#refs/heads/} | sed 's/[^a-zA-Z0-9]/-/g')" >> $GITHUB_OUTPUT | |
| # Copy docs content to mkdocs/docs/ | |
| - name: Copy docs content | |
| run: | | |
| mkdir -p mkdocs/docs | |
| cp -r docs-source/* mkdocs/docs/ | |
| # Copy docs content to mkdocs/docs/ | |
| - name: Debug docs content | |
| run: | | |
| ls -lah mkdocs/ | |
| # Deploy with mike | |
| - name: Deploy with mike | |
| working-directory: mkdocs | |
| run: | | |
| git config user.name "GitHub Action" | |
| git config user.email "[email protected]" | |
| # Deploy version, set 'latest' alias if branch is cells-v4 | |
| if [ "${{ steps.branch.outputs.branch_name }}" = "cells-v4" ]; then | |
| mike deploy --push --update-aliases "${{ steps.branch.outputs.branch_name }}" latest | |
| fi | |
| # Deploy version pydio-v8 | |
| if [ "${{ steps.branch.outputs.branch_name }}" = "pydio-v8" ]; then | |
| mike deploy --push --update-aliases "${{ steps.branch.outputs.branch_name }}" | |
| fi | |
| # Copy docs content to mkdocs/docs/ | |
| - name: Debug working dir content | |
| run: | | |
| ls -lah mkdocs | |
| # Copy specific file to gh-pages | |
| - name: Copy custom index file to 'version' repo in gh-pages | |
| working-directory: mkdocs | |
| run: | | |
| git config user.name "GitHub Action" | |
| git config user.email "[email protected]" | |
| # mkdir -p assets # Create target directory if needed | |
| ls -lah | |
| git branch -a | |
| cp resources/fix_index.html "${{ steps.branch.outputs.branch_name }}"/index.html | |
| git add "${{ steps.branch.outputs.branch_name }}"/index.html | |
| git commit -m "Add custom index to gh-pages" || echo "No changes to commit" | |
| git push origin gh-pages | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.MKDOCS_TOKEN }} |