1+ name : Nitro Docs
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ paths :
8+ - ' docs/**'
9+ pull_request :
10+ branches :
11+ - main
12+ paths :
13+ - ' docs/**'
14+ - ' .github/workflows/docs.yml'
15+ # Review gh actions docs if you want to further define triggers, paths, etc
16+ # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
17+
18+ jobs :
19+ deploy :
20+ name : Deploy to GitHub Pages
21+ runs-on : ubuntu-latest
22+ steps :
23+ - uses : actions/checkout@v3
24+ - uses : actions/setup-node@v3
25+ with :
26+ node-version : 18
27+
28+ - name : Install jq
29+ uses : dcarbone/install-jq-action@v2.0.1
30+
31+ - name : Fill env vars
32+ run : |
33+ env_example_file=".env.example"
34+ touch .env
35+ while IFS= read -r line || [[ -n "$line" ]]; do
36+ if [[ "$line" == *"="* ]]; then
37+ var_name=$(echo $line | cut -d '=' -f 1)
38+ echo $var_name
39+ var_value="$(jq -r --arg key "$var_name" '.[$key]' <<< "$SECRETS")"
40+ echo "$var_name=$var_value" >> .env
41+ fi
42+ done < "$env_example_file"
43+ working-directory : docs
44+ env :
45+ SECRETS : ' ${{ toJson(secrets) }}'
46+
47+ - name : Install dependencies
48+ run : yarn install
49+ working-directory : docs
50+ - name : Build website
51+ run : sed -i '/process.env.DEBUG = namespaces;/c\// process.env.DEBUG = namespaces;' ./node_modules/debug/src/node.js && yarn build
52+ working-directory : docs
53+
54+ - name : Add Custome Domain file
55+ if : github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
56+ run : echo "${{ vars.DOCUSAURUS_DOMAIN }}" > ./docs/build/CNAME
57+
58+ # Popular action to deploy to GitHub Pages:
59+ # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
60+ - name : Deploy to GitHub Pages
61+ if : github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
62+ uses : peaceiris/actions-gh-pages@v3
63+ with :
64+ github_token : ${{ secrets.GITHUB_TOKEN }}
65+ # Build output to publish to the `gh-pages` branch:
66+ publish_dir : ./docs/build
67+ # The following lines assign commit authorship to the official
68+ # GH-Actions bot for deploys to `gh-pages` branch:
69+ # https://github.com/actions/checkout/issues/13#issuecomment-724415212
70+ # The GH actions bot is used by default if you didn't specify the two fields.
71+ # You can swap them out with your own user credentials.
72+ user_name : github-actions[bot]
73+ user_email : 41898282+github-actions[bot]@users.noreply.github.com
0 commit comments