Merge pull request #72 from planetf1/fix/remove-fork-staging-special-… #7
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: Docs | |
| # Builds, validates, and deploys Docusaurus documentation to GitHub Pages. | |
| # | |
| # URL structure (routeBasePath: '/', baseUrl: /{repo-name}/granite/docs/): | |
| # Fork → https://<user>.github.io/<repo-name>/granite/docs/ | |
| # Upstream → https://ibm-granite.github.io/docs/granite/docs/ (repo stays named 'docs') | |
| # IBM.com → https://www.ibm.com/granite/docs/ (Akamai proxies /granite/docs/*) | |
| # | |
| # The deploy job copies the build into gh-deploy/granite/docs/ then publishes gh-deploy/ as | |
| # the gh-pages branch root. GitHub Pages serves it at /{repo-name}/granite/docs/ for any | |
| # repo name — no rename required. All assets (JS, CSS, fonts) also land under granite/docs/, | |
| # so one Akamai rule covers pages and assets with no path rewriting. | |
| # | |
| # Akamai ask (one change only): update the target of the existing /granite/docs/* rule from | |
| # ibmgranite.mintlify.app/granite/docs → ibm-granite.github.io/docs/granite/docs | |
| # Remove the /mintlify-assets/* rule. No new rules, no path rewriting. | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| schedule: | |
| - cron: '17 6 * * 1' # Mondays 06:17 UTC | |
| workflow_dispatch: | |
| permissions: {} | |
| concurrency: | |
| group: docs-publish-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| # Upstream (ibm-granite/docs): /granite/docs/ — matches the IBM.com public path so the | |
| # single Akamai proxy rule covers pages and all assets. Direct GitHub Pages URL is | |
| # intentionally broken; access via www.ibm.com/granite/docs/ only. | |
| # Forks: /{repo-name}/granite/docs/ — matches their GitHub Pages serving path so | |
| # direct preview at username.github.io/{repo-name}/granite/docs/ works. | |
| DOCS_BASE_URL: ${{ github.repository == 'ibm-granite/docs' && '/granite/docs/' || format('/{0}/granite/docs/', github.event.repository.name) }} | |
| # Upstream (ibm-granite/docs): www.ibm.com — canonical domain for SEO, og:url, og:image, | |
| # and sitemap. Forks: github.io — correct for GitHub Pages preview links. | |
| DOCS_SITE_URL: ${{ github.repository == 'ibm-granite/docs' && 'https://www.ibm.com' || format('https://{0}.github.io', github.repository_owner) }} | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" | |
| jobs: | |
| # --------------------------------------------------------------------------- | |
| # Build & Validate | |
| # --------------------------------------------------------------------------- | |
| build-and-validate: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build Docusaurus site | |
| id: build_site | |
| run: npm run build | |
| env: | |
| DOCS_BASE_URL: ${{ env.DOCS_BASE_URL }} | |
| - name: Lint markdown (markdownlint) | |
| id: markdownlint | |
| run: | | |
| npx --yes markdownlint-cli2 "granite/docs/**/*.mdx" "granite/docs/**/*.md" \ | |
| --config granite/docs/.markdownlint.json 2>&1 | |
| continue-on-error: true | |
| - name: Spell check (codespell) | |
| id: codespell | |
| run: | | |
| pip install codespell --quiet | |
| codespell granite/docs \ | |
| --skip="*.json" \ | |
| --quiet-level=2 | |
| continue-on-error: true | |
| - name: Upload built site artifact | |
| if: success() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: docs-site | |
| path: build/ | |
| retention-days: 7 | |
| # --------------------------------------------------------------------------- | |
| # External link check (scheduled + manual, not on every PR) | |
| # --------------------------------------------------------------------------- | |
| link-check: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| persist-credentials: false | |
| - name: Check external links (lychee) | |
| uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0 | |
| with: | |
| args: > | |
| --accept 200,206,429 | |
| --exclude-path granite/docs/resources | |
| --exclude "https://www.ibm.com" | |
| --exclude "https://www.ibm.com/granite" | |
| --timeout 20 | |
| granite/docs | |
| fail: false | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| # --------------------------------------------------------------------------- | |
| # Deploy to GitHub Pages | |
| # --------------------------------------------------------------------------- | |
| deploy: | |
| needs: build-and-validate | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| timeout-minutes: 10 | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Download site artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | |
| with: | |
| name: docs-site | |
| path: docs-site/ | |
| - name: Prepare GitHub Pages tree | |
| run: | | |
| mkdir -p gh-deploy/granite/docs | |
| cp -r docs-site/. gh-deploy/granite/docs/ | |
| touch gh-deploy/.nojekyll | |
| - name: Deploy to GitHub Pages (gh-pages branch) | |
| uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_branch: gh-pages | |
| publish_dir: gh-deploy/ | |
| force_orphan: true | |
| disable_nojekyll: true | |
| user_name: "github-actions[bot]" | |
| user_email: "github-actions[bot]@users.noreply.github.com" | |
| commit_message: | | |
| docs: publish from ${{ github.sha }} | |
| Trigger: ${{ github.event_name }} | |
| Run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| - name: Write deploy summary | |
| if: always() | |
| run: | | |
| echo "## Docs Deploy" >> $GITHUB_STEP_SUMMARY | |
| echo "| | |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-|-|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Branch | \`gh-pages\` |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Source | \`${GITHUB_SHA:0:7}\` |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Base URL | \`$DOCS_BASE_URL\` |" >> $GITHUB_STEP_SUMMARY |