Skip to content

Commit

Permalink
Add CI for deploying pull request previews (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens authored Mar 8, 2024
1 parent c2af895 commit 232ff8b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main
workflow_dispatch:
concurrency:
group: staging
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
deploy:
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ const config: Config = {
url: 'https://theoplayer.prudentgiraffe.com/',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
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.
Expand Down

0 comments on commit 232ff8b

Please sign in to comment.