diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7e34cb65..72754dc2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Release +name: release npm package on: push: @@ -24,12 +24,13 @@ jobs: run: | pnpm install pnpm run build - # pnpm run docs:build - # - name: Deploy Docs - # uses: JamesIves/github-pages-deploy-action@4.1.4 - # with: - # branch: gh-pages - # folder: docs/.vitepress/dist + pnpm run docs:build + - name: Deploy Docs + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + branch: gh-pages + folder: docs/.vitepress/dist + clean-exclude: pr-preview - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 00000000..05257425 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,43 @@ +# https://github.com/rossjrw/pr-preview-action +name: deploy docs + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed + +concurrency: preview-${{ github.ref }} + +jobs: + deploy-preview: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: corepack enable + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: 18 + cache: pnpm + + - name: Install & Build + if: github.event.action != 'closed' # You might want to skip the build if the PR has been closed + env: + VITEPRESS_BASE: test + run: | + pnpm install + pnpm run build + pnpm run docs:build + + - name: Deploy + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./docs/.vitepress/dist/ diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 2636abff..3c23368c 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -101,7 +101,7 @@ export default withPwa( }, pwa: { mode: 'development', - base: '/', + base: `/${process.env.VITEPRESS_BASE ?? ''}`, scope: '/', registerType: 'autoUpdate', // injectRegister: 'inline',