66 paths :
77 - docs/**
88 - " .github/workflows/docs.yml"
9- push :
10- branches : [main]
11- paths :
12- - docs/**
13- - " .github/workflows/docs.yml"
149 workflow_dispatch :
1510
1611permissions :
1712 contents : write
1813
1914jobs :
2015 test-deploy :
21- if : github.event_name != 'push '
16+ if : github.event_name == 'pull_request '
2217 runs-on : ubuntu-latest
2318 steps :
2419 - uses : actions/checkout@v4
25- with :
26- fetch-depth : 0
27- sparse-checkout : docs
28- path : src-staging
29- - name : Move docs
30- run : |
31- shopt -s dotglob
32- mv src-staging/docs/* .
3320 - uses : actions/setup-node@v4
3421 with :
3522 node-version : 18
3623 cache : yarn
24+ cache-dependency-path : docs/yarn.lock
3725 - name : Install dependencies
38- run : yarn install --frozen-lockfile
26+ run : yarn --cwd docs install --frozen-lockfile
3927 - name : Test build website
40- run : yarn build
41-
42- deploy-precheck :
43- if : ${{ github.event_name != 'pull_request' }}
44- runs-on : ubuntu-latest
45- environment : docs-release
46- outputs :
47- gh-deploy-key : ${{ steps.gh-deploy-key.outputs.defined }}
48- steps :
49- - id : gh-deploy-key
50- env :
51- GH_PAGES_DEPLOY : ${{ secrets.GH_PAGES_DEPLOY }}
52- if : " ${{ env.GH_PAGES_DEPLOY != '' }}"
53- run : echo "defined=true" >> $GITHUB_OUTPUT
28+ run : yarn --cwd docs build
5429
5530 deploy :
56- needs : [deploy-precheck]
57- if : ${{ needs.deploy-precheck.outputs.gh-deploy-key == 'true' }}
58- runs-on : ubuntu-latest
59- environment : docs-release
60- steps :
61- - uses : actions/checkout@v4
62- with :
63- fetch-depth : 0
64- sparse-checkout : docs
65- path : src-staging
66- - name : Move docs
67- run : |
68- shopt -s dotglob
69- mv src-staging/docs/* .
70- - uses : actions/setup-node@v4
71- with :
72- node-version : 18
73- cache : yarn
74- -
uses :
webfactory/[email protected] 75- with :
76- ssh-private-key : ${{ secrets.GH_PAGES_DEPLOY }}
77- - name : Deploy to GitHub Pages
78- env :
79- USE_SSH : true
80- run : |
81- export COCOINDEX_DOCS_POSTHOG_API_KEY=${{ vars.COCOINDEX_DOCS_POSTHOG_API_KEY }}
82- export COCOINDEX_DOCS_MIXPANEL_API_KEY=${{ vars.COCOINDEX_DOCS_MIXPANEL_API_KEY }}
83- export COCOINDEX_DOCS_ALGOLIA_APP_ID=${{ vars.COCOINDEX_DOCS_ALGOLIA_APP_ID }}
84- export COCOINDEX_DOCS_ALGOLIA_API_KEY=${{ vars.COCOINDEX_DOCS_ALGOLIA_API_KEY }}
85- git config --global user.email "${{ vars.COCOINDEX_DOCS_DEPLOY_USER_EMAIL }}"
86- git config --global user.name "${{ vars.COCOINDEX_DOCS_DEPLOY_USER_NAME }}"
87- yarn install --frozen-lockfile
88- yarn deploy
31+ name : Release Docs
32+ if : ${{ github.event_name == 'workflow_dispatch' }}
33+ uses : ./.github/workflows/_doc_release.yml
34+ secrets : inherit
0 commit comments