Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI for deploying pull request previews #10

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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