-
Notifications
You must be signed in to change notification settings - Fork 8
61 lines (56 loc) · 1.71 KB
/
docs_publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 == '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