forked from deepjavalibrary/djl
-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (196 loc) · 7 KB
/
docs.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Docs
on:
pull_request:
paths:
- "docs/mkdocs.yml"
# Publish docs weekly
schedule:
- cron: '0 9 * * 1'
workflow_dispatch:
inputs:
is-new-version:
type: boolean
description: Deploying new version? If not, skip the next four parameters.
default: false
required: true
version-number:
type: string
description: What is the new version number for the website?
default: dev
required: false
djl-tag:
type: string
description: The commit SHA (e.g. 6b642e1) for the tag of the version of djl.
default: 'DJL SHA'
required: false
djl-serving-tag:
type: string
description: The commit SHA (e.g. 6b642e1) for the version of djl-serving.
default: 'DJL Serving SHA'
required: false
djl-demo-tag:
description: The commit SHA (e.g. 6b642e1) for the version of djl-demo.
default: 'DJL Demo SHA'
required: false
testing:
type: boolean
description: Is this a test run that will be build into gamma account?
default: false
required: false
testing-credentials:
type: string
description: Provide the bash credentials
default: Bash Credentials
required: false
jobs:
documentation:
# Change line below
if: github.repository == 'Varun-Dutta/djl'
runs-on: ubuntu-latest
steps:
# - name: Set up JDK 17
# uses: actions/setup-java@v4
# with:
# distribution: 'corretto'
# java-version: 17
- name: Set up Python3
uses: actions/setup-python@v5
with:
python-version: '3.x'
# - name: Install CN fonts
# run: sudo apt-get update && sudo apt-get install fonts-arphic-uming
- name: install Python Dependencies
run: pip3 install nbconvert mkdocs==1.4.3 mkdocs-exclude mknotebooks mkdocs-material jupyter Pygments Markdown mike
# - name: Install IJava kernel
# run: |
# git clone https://github.com/frankfliu/IJava.git
# cd IJava/
# ./gradlew installKernel
- name: Create website directory
run: |
cd /home/runner/work/djl
mkdir site
pwd
ls
- name: Checkout Previous Version of DJL Repo
if: ${{ github.event.inputs.is-new-version == 'true' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.djl-tag }}
- name: Checkout Current Version of DJL Repo
if: ${{ github.event.inputs.is-new-version == 'false' }}
uses: actions/checkout@v4
- name: Add mybinder link
run: |
python3 tools/scripts/add_online_runner.py
- name: Clone DJL-Serving and DJL Demos
env:
NEW_VERSION_BOOLEAN: ${{ github.event.inputs.is-new-version }}
DJL_DEMO_SHA: ${{ github.event.inputs.djl-demo-tag }}
DJL_SERVING_SHA: ${{ github.event.inputs.djl-serving-tag }}
run: |
pwd
cd /home/runner/work/djl/djl
rm index.html
git add .
git commit -m "Removed index.html"
cd docs
git clone https://github.com/deepjavalibrary/djl-demo.git demos
git clone https://github.com/deepjavalibrary/djl-serving.git serving
if [ "$NEW_VERSION_BOOLEAN" = "true" ]; then
cd demos
git checkout $DJL_DEMO_SHA
cd ../serving
git checkout $DJL_SERVING_SHA
cd ..
fi
shell: bash
# - name: run Notebooks
# run: |
# cd docs/demos/jupyter
# bash test_notebook.sh
- name: Configure AWS Test Credentials
if: ${{ github.event.inputs.testing == 'true' }}
id: set_credentials
env:
SCRIPT: ${{ github.event.inputs.testing-credentials }}
run: |
echo "$SCRIPT" > script.sh
chmod +x script.sh
source ./script.sh
echo "AWS_DEFAULT_REGION=us-east-1" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" >> $GITHUB_ENV
echo "AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN" >> $GITHUB_ENV
- name: Configure Deployment AWS Credentials
if: ${{ github.event_name != 'pull_request' && github.event.inputs.testing != 'true' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Sync gh-pages
env:
TESTING: ${{ github.event.inputs.testing }}
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "Standardizing Branch"
git checkout -b docs-branch
cd /home/runner/work/djl/djl/docs
git branch gh-pages
mike delete --all
git checkout gh-pages
cd ..
if [ "$TESTING" = 'true' ]; then
echo "Attempting sync"
if [ -d ./docs ]; then
rm -rf ./docs
fi
aws s3 cp s3://updated-documentation-website/website/ ./ --recursive
else
aws s3 sync s3://djl-ai/documentation/nightly .
fi
git add .
git commit -m "Synced gh-pages with S3"
git checkout docs-branch
shell: bash
#Double Check
- name: build docs
env:
VERSION_NUMBER: ${{ github.event.inputs.version-number }}
IS_NEW_VERSION: ${{ github.event.inputs.is-new-version }}
run: |
cd /home/runner/work/djl/djl
rm index.html
cd docs
export DJL_DISABLE_PROGRESS_BAR=true
if [ "$IS_NEW_VERSION" = "true" ]; then
echo "deploying $VERSION_NUMBER"
mike deploy $VERSION_NUMBER latest
else
mike deploy 1.0 dev
mike set-default dev
fi
git branch
shell: bash
- name: Copy files to S3 with the AWS CLI
if: github.event_name != 'pull_request'
env:
TESTING: ${{ github.event.inputs.testing }}
run: |
cd /home/runner/work/djl/djl
git checkout gh-pages
git branch
pwd
ls
if [ "$TESTING" = "true" ]; then
echo "TEST SYNC"
aws s3 sync . s3://updated-documentation-website/website/ --exclude ".*" --delete
else
echo "REAL SYNC"
aws s3 sync . s3://djl-ai/documentation/nightly --delete
aws cloudfront create-invalidation --distribution-id E733IIDCG0G5U --paths "/*"
fi
shell: bash