Skip to content

Docs

Docs #50

Workflow file for this run

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