Skip to content

Commit

Permalink
refactor document build ci
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfliu committed Jul 31, 2024
1 parent 5183fb4 commit 4e9c6bf
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 364 deletions.
98 changes: 33 additions & 65 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,41 @@
name: Docs
#This workflow automates updating the dev version of the documentation website and the deployment of new versions of the document website.
on:
pull_request:
# Publish docs weekly
schedule:
- cron: '0 9 * * 1'
- cron: '0 9 * * 1'
workflow_dispatch:
inputs:
testing:
type: boolean
description: Is this a test run that will be built into gamma account?
default: false
required: false
version-number:
type: string
description: What is the new version number (ex. v0.28.0) for the website? If updating dev, leave this blank.
type: string
description: What is the new version number (ex. v0.28.0) for the website? If updating dev, leave this blank.
default: master
required: false

permissions:
id-token: write
contents: read
jobs:
id-token: write
contents: read

jobs:
documentation:
if: github.repository == 'deepjavalibrary/djl'
runs-on: ubuntu-latest
steps:
#Phase I: Set-up
#This phase sets up all of the necessary dependencies. This includes installing Java, Python, and adding the tools used to build the documentation website.
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: 17

- name: Set up Python
- name: Set up Python3
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Python Dependencies
run: pip3 install nbconvert mkdocs==1.4.3 mkdocs-exclude mknotebooks mkdocs-material jupyter Pygments Markdown mike

- 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: Cache IJava Kernel
id: ijava-cache
uses: actions/cache@v4
Expand All @@ -59,69 +50,46 @@ jobs:
cd IJava/
./gradlew installKernel
#Phase II: Consolidate the Source Files
#This phase consolidates all of the source files (i.e. Markdown files and Jupyter Notebooks) that are converted into the html files that form the documenetation website.
#These files are split across the DJL, DJL-Demo, and DJL-Serving Repository. They need to be consolidated locallay and inaccordance with paths specified in the mkdocs.yml file in djl/docs.
- name: Create website directory
run: |
cd /home/runner/work/djl
mkdir site
- name: Checkout DJL Repo
uses: actions/checkout@v4
with:
with:
ref: ${{ github.event.version-number }}

#This step is necessary because the index.html file in djl/index.html overwrites the index.html file Mike create for the landing page
#This is problematic because this index.html corresponds to the djl website rather than the docs website.
- name: Delete index.html
run: |
rm -f index.html
shell: bash

- name: Checkout DJL-Serving
uses: actions/checkout@v4
with:
repository: 'deepjavalibrary/djl-serving'
repository: 'deepjavalibrary/djl-serving'
ref: ${{ github.event.inputs.version-number || 'master' }}
path: docs/serving

- name: Checkout DJL-Demo
uses: actions/checkout@v4
with:
repository: 'deepjavalibrary/djl-demo'
repository: 'deepjavalibrary/djl-demo'
ref: ${{ github.event.inputs.version-number || 'master' }}
path: docs/demos

- name: Add mybinder link
run: |
python3 tools/scripts/add_online_runner.py

#Phase III: Retrive Current Website
#This phase handles authentication with AWS.
- name: Configure AWS Test Credentials
if: ${{ github.event.inputs.testing == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
with:
audience: sts.amazonaws.com
aws-region: us-east-1
role-to-assume: arn:aws:iam::185921645874:role/UpdateWebsite
role-session-name: UpdateWebsite

- name: run Notebooks
working-directory: docs/demos/jupyter
env:
DJL_DISABLE_PROGRESS_BAR: true
run: bash test_notebook.sh

- name: Build docs website
run: tools/scripts/build-website.sh "${{ github.event.inputs.version-number || 'master' }}"

- 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

#Phase IV: Build and Deploy New Website
- name: Build New Version
env:
TESTING_FLAG: ${{ github.event.inputs.testing }}
- name: Copy files to S3 with the AWS CLI
run: |
echo "Building Website"
chmod +x build-website.sh
./build-website.sh -t "$TESTING_FLAG" -v "${{ github.event.inputs.version-number }}"
export DJL_VERSION=${{ github.event.inputs.pt_version || 'master' }}
aws s3 sync $DJL_VERSION s3://djl-ai/documentation/nightly/$DJL_VERSION --delete
# aws s3 cp versions.json s3://djl-ai/documentation/nightly/
# aws s3 cp index.html s3://djl-ai/documentation/nightly/
aws cloudfront create-invalidation --distribution-id E733IIDCG0G5U --paths "/*"
71 changes: 0 additions & 71 deletions build-website.sh

This file was deleted.

Loading

0 comments on commit 4e9c6bf

Please sign in to comment.