docs-updated #4
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: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| repository_dispatch: | |
| types: [docs-updated] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout website repo | |
| uses: actions/checkout@v4 | |
| # --- Pull docs from plugin repos --- | |
| - name: Checkout MyTrip docs | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ChafficPlugins/MyTrip | |
| path: _repos/mytrip | |
| sparse-checkout: docs | |
| - name: Checkout MiningLevels docs | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ChafficPlugins/MiningLevels | |
| path: _repos/mininglevels | |
| sparse-checkout: docs | |
| - name: Checkout CrucialLib docs | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ChafficPlugins/CrucialLib | |
| path: _repos/cruciallib | |
| sparse-checkout: docs | |
| - name: Aggregate docs from all repos | |
| run: | | |
| for repo in mytrip mininglevels cruciallib; do | |
| if [ -d "_repos/$repo/docs" ]; then | |
| mkdir -p "docs/$repo" | |
| cp -r "_repos/$repo/docs/." "docs/$repo/" | |
| echo "Copied docs from $repo" | |
| else | |
| echo "No docs/ folder found in $repo (skipping)" | |
| fi | |
| done | |
| # Generate placeholder stubs for any nav entries that don't have | |
| # a real file yet, so MkDocs doesn't warn about missing pages. | |
| grep -oP ':\s+\K\S+\.md' mkdocs.yml | while read -r page; do | |
| if [ ! -f "docs/$page" ]; then | |
| mkdir -p "docs/$(dirname "$page")" | |
| title=$(basename "$page" .md | sed 's/-/ /g; s/\b\(.\)/\u\1/g') | |
| printf '# %s\n\n!!! info "Coming Soon"\n This page is under construction.\n' "$title" > "docs/$page" | |
| echo "Generated placeholder: docs/$page" | |
| fi | |
| done | |
| echo "" | |
| echo "Final docs structure:" | |
| find docs -type f -name "*.md" | sort | |
| # --- Build MkDocs --- | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.x | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| key: mkdocs-material-${{ hashFiles('mkdocs.yml') }} | |
| path: ~/.cache | |
| restore-keys: mkdocs-material- | |
| - name: Install MkDocs Material | |
| run: pip install "mkdocs>=1.6,<2" mkdocs-material | |
| - name: Build docs | |
| run: mkdocs build | |
| # --- Combine landing page + docs into one artifact --- | |
| - name: Assemble site | |
| run: | | |
| mkdir _site | |
| # Landing page files | |
| cp index.html _site/ | |
| cp redirect.html _site/ | |
| cp -r style _site/ | |
| cp -r img _site/ | |
| # MkDocs output → /docs/ | |
| mv site _site/docs | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: _site | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |