docs-deploy.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. name: Docs Deploy (GitHub Pages)
  2. # Static-export deploy of docs/ to GitHub Pages. Pages must be enabled in repo
  3. # settings (Source: GitHub Actions) and the docs.sanaei.dev custom domain
  4. # attached to this repository. The site URL defaults to the production domain in
  5. # docs/lib/shared.ts, so NEXT_PUBLIC_SITE_URL is optional.
  6. on:
  7. push:
  8. branches: [main]
  9. paths:
  10. - 'docs/**'
  11. - '.github/workflows/docs-deploy.yml'
  12. workflow_dispatch:
  13. permissions:
  14. contents: read
  15. pages: write
  16. id-token: write
  17. concurrency:
  18. group: pages
  19. cancel-in-progress: true
  20. defaults:
  21. run:
  22. working-directory: docs
  23. jobs:
  24. build:
  25. runs-on: ubuntu-latest
  26. steps:
  27. - uses: actions/checkout@v7
  28. - uses: pnpm/action-setup@v6
  29. with:
  30. version: 11
  31. - uses: actions/setup-node@v6
  32. with:
  33. node-version: 22
  34. cache: pnpm
  35. cache-dependency-path: docs/pnpm-lock.yaml
  36. - run: pnpm install --frozen-lockfile
  37. - name: Build (static export)
  38. env:
  39. DEPLOY_TARGET: static
  40. NEXT_PUBLIC_SITE_URL: ${{ vars.NEXT_PUBLIC_SITE_URL }}
  41. run: pnpm build
  42. - name: Mirror default locale (en) to the site root
  43. # hideLocale makes most English links unprefixed (/, /docs/...), but the
  44. # language switcher still targets /en/... . The export emits pages only
  45. # under /en/, and there is no i18n middleware on a static host — so copy
  46. # the English build to the root (data files included) while KEEPING /en/
  47. # in place. That way both /docs/... and /en/docs/... resolve. Other
  48. # locales stay under /fa, /ru, /zh.
  49. run: cp -a out/en/. out/
  50. - uses: actions/upload-pages-artifact@v5
  51. with:
  52. path: docs/out
  53. deploy:
  54. needs: build
  55. runs-on: ubuntu-latest
  56. environment:
  57. name: github-pages
  58. url: ${{ steps.deployment.outputs.page_url }}
  59. steps:
  60. - id: deployment
  61. uses: actions/deploy-pages@v5