docs: add versioning #83
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: publish docs to GitHub Pages | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 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 == 'push' && 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 == 'false' | |
run: | | |
nix build -L .#contrast-docs | |
- name: Publish docs to GitHub Pages | |
if: env.PREVIEW == 'false' | |
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 == 'true' | |
run: | | |
nix build -L --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 == 'true' | |
uses: rossjrw/pr-preview-action@f31d5aa7b364955ea86228b9dcd346dc3f29c408 # v1 | |
with: | |
source-dir: ./result |