diff --git a/.github/workflows/branch-deploy.yml b/.github/workflows/branch-deploy.yml new file mode 100644 index 00000000..a63ea40e --- /dev/null +++ b/.github/workflows/branch-deploy.yml @@ -0,0 +1,68 @@ +name: Deploy VitePress site to GitHub Pages + +on: pull_request + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + env: + BRANCH_NAME: ${{ github.ref_name }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Not needed if lastUpdated is not enabled + + - name: Install package manager (from package.json) + run: | + corepack enable + corepack install + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: yarn + + - name: Setup GitHub Pages + uses: actions/configure-pages@v4 + + - name: Install dependencies + run: yarn install + + - name: Yarn audit + run: yarn audit + + - name: Build with VitePress + env: + GENERATE_BUILD_SIZE_VISUALIZER: true + run: yarn build + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: packages/docs/.vitepress/dist + + deploy: + environment: + name: staging + url: ${{ steps.deployment.outputs.page_url }}staging + needs: build + runs-on: ubuntu-latest + name: Deploy + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/packages/docs/.vitepress/config.mts b/packages/docs/.vitepress/config.mts index 440d3ac0..3d99aba1 100644 --- a/packages/docs/.vitepress/config.mts +++ b/packages/docs/.vitepress/config.mts @@ -1,9 +1,10 @@ +import process from 'node:process'; import { kebabCase } from 'change-case'; import { defineConfig } from 'vitepress'; import { getSidebarItems } from './theme/Shared/Config/Lib/getSidebarItems'; export default defineConfig({ - base: '/flyonui-vue/', + base: `/flyonui-vue/${process.env.BRANCH_NAME === undefined ? '' : 'staging'}`, rewrites: (id) => { const format = '.md';