Build and publish the documentation #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish the documentation | |
on: | |
workflow_dispatch: | |
inputs: | |
publish: | |
description: 'Whether to publish the documentation (as opposed to just building it)' | |
required: false | |
default: true | |
type: boolean | |
environment: | |
description: 'Whether to publish to production or test environment' | |
required: false | |
default: prod | |
type: choice | |
options: [prod, test] | |
ref: | |
description: 'The git ref to build the documentation for' | |
required: false | |
default: '' | |
type: string | |
use_lkg: | |
description: 'Whether to use the last known good versions of dependencies' | |
required: false | |
default: True | |
type: boolean | |
run_doctests: | |
description: 'Whether to run doctests' | |
required: false | |
default: True | |
type: boolean | |
# annoyingly, there does not seem to be a way to share these input definitions between triggers | |
workflow_call: | |
inputs: | |
publish: | |
description: 'Whether to publish the documentation (as opposed to just building it)' | |
required: false | |
default: true | |
type: boolean | |
# choice type only supported for workflow_dispatch, not workflow_call | |
environment: | |
description: 'Whether to publish to production or test environment' | |
required: false | |
default: prod | |
type: string | |
ref: | |
description: 'The git ref to build the documentation for' | |
required: false | |
default: '' | |
type: string | |
use_lkg: | |
description: 'Whether to use the last known good versions of dependencies' | |
required: false | |
default: True | |
type: boolean | |
run_doctests: | |
description: 'Whether to run doctests' | |
required: false | |
default: True | |
type: boolean | |
jobs: | |
create_docs: | |
name: Create and publish documentation | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref }} | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 # because of our supported TensorFlow versions, must build on 3.6-3.8 | |
- name: Ensure latest pip and setuptools | |
run: python -m pip install --upgrade pip && pip install --upgrade setuptools | |
- name: Install econml[all] | |
run: pip install -e .[all] ${{ inputs.use_lkg && '-r lkg.txt' || '' }} | |
- name: Install graphviz | |
run: sudo apt-get -yq install graphviz | |
- name: Build documentation | |
run: pip install "sphinx~=4.4.0" "sphinx_rtd_theme~=1.0.0" && python setup.py build_sphinx -W | |
- name: Upload docs as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs | |
path: build/sphinx/html/ | |
- name: Run doctests | |
run: python setup.py build_sphinx -b doctest | |
if : ${{ inputs.run_doctests }} | |
publish-docs: | |
name: Publish documentation | |
needs: create_docs | |
permissions: | |
id-token: write # needed to publish to Azure | |
environment: ${{ inputs.environment }} | |
if: ${{ inputs.publish }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download docs artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: docs | |
path: html | |
- name: Zip docs for publishing | |
run: |- | |
pushd html | |
zip -r docs.zip * | |
popd | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Deploy documentation to Azure web app | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: ${{ inputs.environment == 'prod' && 'econml' || 'econml-dev' }} | |
package: html/docs.zip |