docs-deploy.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. - 'frontend/src/components/**'
  12. - 'frontend/.storybook/**'
  13. - 'frontend/package-lock.json'
  14. - '.github/workflows/docs-deploy.yml'
  15. workflow_dispatch:
  16. permissions:
  17. contents: read
  18. pages: write
  19. id-token: write
  20. concurrency:
  21. group: pages
  22. cancel-in-progress: true
  23. defaults:
  24. run:
  25. working-directory: docs
  26. jobs:
  27. build:
  28. runs-on: ubuntu-latest
  29. steps:
  30. - uses: actions/checkout@v7
  31. - uses: pnpm/action-setup@v6
  32. with:
  33. package_json_file: docs/package.json
  34. - uses: actions/setup-node@v6
  35. with:
  36. node-version-file: .nvmrc
  37. cache: pnpm
  38. cache-dependency-path: docs/pnpm-lock.yaml
  39. - run: pnpm install --frozen-lockfile
  40. - name: Build (static export)
  41. env:
  42. DEPLOY_TARGET: static
  43. NEXT_PUBLIC_SITE_URL: ${{ vars.NEXT_PUBLIC_SITE_URL }}
  44. run: pnpm build
  45. - name: Mirror default locale (en) to the site root
  46. # hideLocale makes most English links unprefixed (/, /docs/...), but the
  47. # language switcher still targets /en/... . The export emits pages only
  48. # under /en/, and there is no i18n middleware on a static host — so copy
  49. # the English build to the root (data files included) while KEEPING /en/
  50. # in place. That way both /docs/... and /en/docs/... resolve. Other
  51. # locales stay under /fa, /ru, /zh.
  52. run: cp -a out/en/. out/
  53. - name: Build the component Storybook (frontend/)
  54. working-directory: frontend
  55. run: |
  56. npm ci
  57. npm run build-storybook
  58. - name: Bundle Storybook at /storybook
  59. run: cp -a ../frontend/storybook-static out/storybook
  60. - uses: actions/upload-pages-artifact@v5
  61. with:
  62. path: docs/out
  63. deploy:
  64. needs: build
  65. runs-on: ubuntu-latest
  66. environment:
  67. name: github-pages
  68. url: ${{ steps.deployment.outputs.page_url }}
  69. steps:
  70. - id: deployment
  71. uses: actions/deploy-pages@v5