-
Notifications
You must be signed in to change notification settings - Fork 28
127 lines (125 loc) · 4.96 KB
/
build-doc.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
name: Build doc
on:
workflow_call:
inputs:
doc-artifact-name:
description: "Name of the artifact containing the built doc"
required: false
default: "doc"
type: string
doc-path:
description: "Path where to find the built doc"
required: false
default: "docs/.vuepress/dist"
type: string
doc-version:
description: "version of the library for which we are building the doc. If empty, then it is main branch doc."
required: FALSE
default: ""
type: string
notebooks-repo-url:
description: |
Url of the repository containing the notebooks, used to generate github and colab links.
By default, the current repository url.
required: false
default: ""
type: string
notebooks-branch:
description: |
Branch containing the notebooks, used to generate github and colab links.
By default, the current branch.
required: false
default: ""
type: string
doc-prerequisites-cmdline:
description: |
Command line to run before building doc.
required: false
default: ""
type: string
jobs:
build-doc:
runs-on: ubuntu-latest
env:
python-version: "3.10"
steps:
- name: Set env variables for github links in doc
run: |
# notebooks source repo and branch. First try to use workflow inputs
AUTODOC_NOTEBOOKS_REPO_URL=${{ inputs.notebooks-repo-url }}
AUTODOC_NOTEBOOKS_BRANCH=${{ inputs.notebooks-branch }}
# use github context if not defined in inputs
if [[ $GITHUB_REF == refs/pull* ]];
then
if [ -z "${AUTODOC_NOTEBOOKS_REPO_URL}" ]; then
AUTODOC_NOTEBOOKS_REPO_URL="${GITHUB_SERVER_URL}/${{ github.event.pull_request.head.repo.full_name }}"
fi
if [ -z "${AUTODOC_NOTEBOOKS_BRANCH}" ]; then
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_HEAD_REF}
fi
elif [[ $GITHUB_REF == refs/heads* ]];
then
if [ -z "${AUTODOC_NOTEBOOKS_REPO_URL}" ]; then
AUTODOC_NOTEBOOKS_REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
fi
if [ -z "${AUTODOC_NOTEBOOKS_BRANCH}" ]; then
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_REF/refs\/heads\//}
fi
elif [[ $GITHUB_REF == refs/tags* ]];
then
if [ -z "${AUTODOC_NOTEBOOKS_REPO_URL}" ]; then
AUTODOC_NOTEBOOKS_REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
fi
if [ -z "${AUTODOC_NOTEBOOKS_BRANCH}" ]; then
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_REF/refs\/tags\//}
fi
fi
# export in GITHUB_ENV for next steps
echo "AUTODOC_NOTEBOOKS_REPO_URL=${AUTODOC_NOTEBOOKS_REPO_URL}" >> $GITHUB_ENV
echo "AUTODOC_NOTEBOOKS_BRANCH=${AUTODOC_NOTEBOOKS_BRANCH}" >> $GITHUB_ENV
# check computed variables
echo "Notebooks source: ${AUTODOC_NOTEBOOKS_REPO_URL}/tree/${AUTODOC_NOTEBOOKS_BRANCH}"
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
cache: "pip"
cache-dependency-path: |
pyproject.toml
- name: Download wheel
uses: actions/download-artifact@v4
with:
pattern: wheels-ubuntu*-${{ env.python-version }}
merge-multiple: true
path: wheels
- name: Install scikit-decide wheel and dependencies
run: |
python -m pip install -U pip setuptools
# find proper wheel and install it
python_version=${{ env.python-version }}
wheelfile=$(ls ./wheels/scikit_decide*-cp${python_version/\./}-*manylinux*.whl)
pip install ${wheelfile}[all]
- name: set env.DOCS_VERSION_PATH aka subpath where the doc will be deployed
# DOCS_VERSION_PATH is used by yarn docs:build to preprend links to javascript with proper subpath
# See docs/.vuepress/config.js
id: set-doc-version-path
run: |
doc_version=${{ inputs.doc-version }}
if [ -z "${doc_version}" ]; then
doc_version_path="/"
else
doc_version_path="/version/${doc_version}/"
fi
echo "DOCS_VERSION_PATH=${doc_version_path}" >> $GITHUB_ENV
- name: generate documentation
run: |
yarn global add vuepress && yarn install
export NODE_OPTIONS=--openssl-legacy-provider # avoid issue with node 18 and current dependencies (ok because no interaction with external network during the build)
yarn docs:build
touch docs/.vuepress/dist/.nojekyll
- name: upload as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.doc-artifact-name }}
path: ${{ inputs.doc-path }}