Skip to content

Commit

Permalink
ci: deploy docs preview on pr
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Mar 18, 2024
1 parent 2e967c6 commit ee759b0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/docs_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,53 @@ on:
- docs/**
- .github/workflows/docs_publish.yml
- packages/contrast-docs/**
pull_request:
types:
- opened
- reopened
- synchronize
- closed
paths:
- docs/**
- .github/workflows/docs_publish.yml
- packages/contrast-docs/**

permissions:
contents: write
pull-requests: write

jobs:
deploy:
name: Publish docs to GitHub Pages
runs-on: ubuntu-22.04
env:
PREVIEW: ${{ github.event_name == 'pull_request' && github.ref_name != 'main' }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/setup_nix
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
cachixToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build production website
if: (!env.PREVIEW)
run: |
nix build .#contrast-docs
- name: Publish docs to GitHub Pages
if: (!env.PREVIEW)
uses: JamesIves/github-pages-deploy-action@65b5dfd4f5bcd3a7403bbc2959c144256167464e # v4.5.0
with:
folder: ./result
branch: gh-pages
clean-exclude: pr-preview
force: false

- name: Build preview website
if: env.PREVIEW
run: |
nix build --impure --expr "(builtins.getFlake \"git+file://$(pwd)?shallow=1\").outputs.legacyPackages.x86_64-linux.contrast-docs.override { docusaurusBaseUrl = \"contrast/pr-preview/pr-${{ github.event.number }}\"; }"
- name: Deploy preview
if: env.PREVIEW
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./result

0 comments on commit ee759b0

Please sign in to comment.