-
Notifications
You must be signed in to change notification settings - Fork 5
116 lines (109 loc) · 3.62 KB
/
force-docs-build.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Manual Docs Build
on:
workflow_dispatch:
inputs:
release_token:
description: 'Your release token'
required: true
triggered_by:
description: 'CD | TAG | MANUAL'
required: false
default: MANUAL
package:
description: The name of the repo to build documentation for.
type: string
default: marie-ai
repo_owner:
description: The owner of the repo to build documentation for. Defaults to 'marie-ai'.
type: string
default: marie-ai
pages_branch:
description: Branch that Github Pages observes
type: string
default: gh-pages
git_config_name:
type: string
default: Marie Dev Bot
git_config_email:
type: string
default: [email protected]
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
env:
# Hosted GitHub runners have 7 GB of memory available, let's use 6 GB
NODE_OPTIONS: --max-old-space-size=6144
jobs:
token-x:
runs-on: ubuntu-latest
steps:
- name: Check release token
id: token-checkxxx
run: |
echo "${{ github.event.inputs.release_token }} == ${{ env.release_token }}"
env:
release_token: ${{ secrets.MARIE_CORE_RELEASE_TOKEN }}
token-check:
runs-on: ubuntu-latest
steps:
- name: Check release token
id: token-check
run: |
touch SUCCESS
if: "${{ github.event.inputs.release_token }} == ${{ env.release_token }}"
env:
release_token: ${{ secrets.MARIE_CORE_RELEASE_TOKEN }}
- name: Fail release token
run: |
[[ -f SUCCESS ]]
build-and-push-latest-docs:
# needs: token-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-node@v3
with:
node-version: 16.x
cache: yarn
- name: Install Yarn # Self hosted runners need to install YARN
run: npm install -g yarn
- name: Install Dependencies
run: |
cd docs
yarn install --frozen-lockfile --non-interactive
- name: Docusaurus Build
run: |
cd docs
yarn build
mv ./build /tmp/gen-html
cd ..
- name: Checkout to GH pages branch (${{ inputs.pages_branch }})
run: |
git fetch origin ${{ inputs.pages_branch }}:${{ inputs.pages_branch }} --depth 1
git checkout -f ${{ inputs.pages_branch }}
git reset --hard HEAD
- name: Small config stuff
run: |
touch /tmp/gen-html/.nojekyll
cp ./docs/_versions.json /tmp/gen-html/_versions.json
cp ./docs/CNAME /tmp/gen-html/CNAME
cp /tmp/gen-html/404/index.html /tmp/gen-html/404.html
sed -i 's/href="\.\./href="/' /tmp/gen-html/404.html # fix asset urls that needs to be updated in 404.html
- name: Moving old doc versions
run: |
cd docs
for i in $(cat _versions.json | jq '.[].version' | tr -d '"'); do if [ -d "$i" ]; then mv "$i" /tmp/gen-html; fi; done
- name: Swap in new docs
run: |
rm -rf ./docs
mv /tmp/gen-html ./docs
- name: Push it up!
run: |
git config --local user.email "${{ inputs.git_config_email }}"
git config --local user.name "${{ inputs.git_config_name }}"
git show --summary
git add ./docs && git commit -m "chore(docs): update docs due to ${{github.event_name}} on ${{github.repository}}"
git push origin ${{ inputs.pages_branch }}