diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c54da4186f5..525d051409f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,7 +5,7 @@ on: - main workflow_dispatch: concurrency: - group: staging + group: ${{ github.workflow }} cancel-in-progress: true jobs: deploy: diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml new file mode 100644 index 00000000000..5cf90663051 --- /dev/null +++ b/.github/workflows/pr-preview.yml @@ -0,0 +1,44 @@ +name: Deploy pull request preview +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed +concurrency: preview-${{ github.ref }} +jobs: + pr-preview: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + submodules: true + # Build the website + - name: Use Node.js 20 + if: github.event.action != 'closed' + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Build + if: github.event.action != 'closed' + run: | + npm ci + npm run build + env: + THEOPLAYER_LICENSE: ${{ vars.THEOPLAYER_LICENSE }} + # Preview URLs look like this: https://[owner].github.io/[repo]/pr-preview/pr-[number]/ + # https://github.com/marketplace/actions/deploy-pr-preview + DOCUSAURUS_BASE_URL: /${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.number }}/ + # Prevent PR previews from being indexed by search engines + DOCUSAURUS_NO_INDEX: 1 + # Deploy preview + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./build/ + preview-branch: gh-pages + umbrella-dir: pr-preview diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 23e5d453528..f7da033499d 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -46,8 +46,9 @@ const config: Config = { url: 'https://theoplayer.prudentgiraffe.com/', // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: '/docs/', + baseUrl: process.env.DOCUSAURUS_BASE_URL || '/docs/', trailingSlash: true, + noIndex: !!process.env.DOCUSAURUS_NO_INDEX, // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these.