feat(theme): add ThemeSwitcher component and useTheme singleton #285
Workflow file for this run
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 Preview | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: docs-pages | |
| cancel-in-progress: false | |
| jobs: | |
| build-preview: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: yarn | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build preview | |
| run: >- | |
| VITEPRESS_BASE=/pr-preview/pr-${{ github.event.pull_request.number }}/ yarn docs:build | |
| - name: Upload preview artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docs-preview | |
| path: docs/.vitepress/dist | |
| publish-preview: | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| needs: build-preview | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout trusted deploy scripts | |
| uses: actions/checkout@v5 | |
| - name: Download preview artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docs-preview | |
| path: docs/.vitepress/dist | |
| - name: Publish preview | |
| run: >- | |
| bash .github/scripts/docs-pages.sh deploy-preview docs/.vitepress/dist ${{ github.event.pull_request.number }} | |
| - name: Append preview URL to PR description | |
| uses: actions/github-script@v7 | |
| env: | |
| PREVIEW_URL: >- | |
| https://ui.frappe.io/pr-preview/pr-${{ github.event.pull_request.number }}/ | |
| with: | |
| script: | | |
| const MARKER_START = '<!-- docs-preview:start -->' | |
| const MARKER_END = '<!-- docs-preview:end -->' | |
| const block = [ | |
| MARKER_START, | |
| `Docs preview: ${process.env.PREVIEW_URL}`, | |
| MARKER_END, | |
| ].join('\n') | |
| const { owner, repo } = context.repo | |
| const pull_number = context.issue.number | |
| const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number }) | |
| const current = pr.body ?? '' | |
| const re = new RegExp(`${MARKER_START}[\\s\\S]*?${MARKER_END}`) | |
| const body = re.test(current) | |
| ? current.replace(re, block) | |
| : `${current.trimEnd()}\n\n${block}\n` | |
| await github.rest.pulls.update({ owner, repo, pull_number, body }) |