Skip to content

Commit 2718702

Browse files
authored
Merge pull request #417 from KhiopsML/415-build-api-documentation-as-release-artifact-instead-of-deploying-it-directly
415 build api documentation as release artifact instead of deploying it directly
2 parents ea474fb + fc0c3e6 commit 2718702

File tree

2 files changed

+46
-37
lines changed

2 files changed

+46
-37
lines changed

.github/workflows/api-docs.yml

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ env:
55
on:
66
workflow_dispatch:
77
inputs:
8-
deploy-gh-pages:
9-
description: Deploy GH Pages
10-
required: true
11-
type: boolean
12-
default: false
138
khiops-python-tutorial-revision:
149
default: main
1510
description: khiops-python-tutorial repo revision
@@ -24,6 +19,8 @@ on:
2419
- doc/*.py
2520
- khiops/**.py
2621
- .github/workflows/api-docs.yml
22+
push:
23+
tags: ['*']
2724
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
2825
permissions:
2926
contents: read
@@ -49,20 +46,10 @@ jobs:
4946
# https://github.com/actions/runner/issues/2033#issuecomment-1598547465
5047
options: --user 1001
5148
steps:
52-
- name: Set parameters as env
53-
run: |
54-
KHIOPS_PYTHON_TUTORIAL_REVISION=${{ inputs.khiops-python-tutorial-revision || env.DEFAULT_KHIOPS_PYTHON_TUTORIAL_REVISION }}
55-
echo "KHIOPS_PYTHON_TUTORIAL_REVISION=$KHIOPS_PYTHON_TUTORIAL_REVISION" >> "$GITHUB_ENV"
5649
- name: Checkout khiops-python
5750
uses: actions/checkout@v4
5851
with:
5952
fetch-depth: 0
60-
- name: Checkout khiops-python-tutorial
61-
uses: actions/checkout@v4
62-
with:
63-
repository: khiopsml/khiops-python-tutorial
64-
ref: ${{ env.KHIOPS_PYTHON_TUTORIAL_REVISION }}
65-
path: doc/khiops-python-tutorial
6653
- name: Add pip scripts directory to path
6754
run: echo PATH="$PATH:/github/home/.local/bin" >> "$GITHUB_ENV"
6855
- name: Install doc build requirements
@@ -75,25 +62,43 @@ jobs:
7562
# Install the doc python requirements
7663
cd doc
7764
pip3 install -U -r requirements.txt
65+
# Clone the Khiops Python tutorial repository while building the documentation
7866
- name: Build Sphinx Documentation
7967
run: |
8068
cd doc
81-
./create-doc -t
69+
./create-doc -t -d -g \
70+
${{ inputs.khiops-python-tutorial-revision || env.DEFAULT_KHIOPS_PYTHON_TUTORIAL_REVISION }}
8271
- name: Upload the docs as an artifact
83-
uses: actions/upload-pages-artifact@v3
72+
uses: actions/upload-artifact@v4
8473
with:
85-
path: doc/_build/html/
86-
# Deploy only when the user explicitly (and manually) orders it
87-
deploy:
88-
if: github.event_name == 'workflow_dispatch' && inputs.deploy-gh-pages == true
89-
runs-on: ubuntu-latest
74+
name: api-docs
75+
path: ./doc/_build/html/
76+
# Release on Git tag
77+
release:
78+
if: github.ref_type == 'tag'
9079
needs: build
91-
environment:
92-
name: github-pages
93-
url: ${{ steps.deployment.outputs.page_url }}
80+
runs-on: ubuntu-22.04
81+
permissions:
82+
contents: write
9483
steps:
95-
- name: Setup Pages
96-
uses: actions/configure-pages@v4
97-
- name: Deploy API Docs to GitHub Pages
98-
id: deployment
99-
uses: actions/deploy-pages@v4
84+
- name: Download docs artifact
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: api-docs
88+
path: ./doc/_build/html/
89+
- name: Create docs release zip archive
90+
uses: thedoctor0/zip-release@0.7.6
91+
with:
92+
type: zip
93+
path: ./doc/_build/html/
94+
filename: khiops-api-docs-${{ github.ref_name }}.zip
95+
- name: Release the docs zip archive
96+
uses: ncipollo/release-action@v1.15.0
97+
with:
98+
allowUpdates: true
99+
artifacts: ./khiops-api-docs-${{ github.ref_name }}.zip
100+
body: '**For testing purposes only**'
101+
draft: false
102+
makeLatest: false
103+
prerelease: true
104+
updateOnlyUnreleased: true

doc/create-doc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
77
# Default parameter values
88
TRANSFORM_NOTEBOOKS=""
99
DOWNLOAD_REPO=""
10-
DEFAULT_KHIOPS_TUTORIAL_REPO_URL="git@github.com:KhiopsML/khiops-python-tutorial.git"
10+
DEFAULT_KHIOPS_TUTORIAL_REPO_URL="https://github.com/KhiopsML/khiops-python-tutorial.git"
11+
DEFAULT_KHIOPS_TUTORIAL_REPO_REF="main"
1112
DEFAULT_KHIOPS_TUTORIAL_DIR="${SCRIPT_DIR}/khiops-python-tutorial"
1213

1314
# Function to display the usage help
1415
usage() {
15-
echo "Usage: create-doc [-r REPO_URL] [-d] [-t] [-l]"
16+
echo "Usage: create-doc [-r REPO_URL] [-d] [-t] [-g] [-l]"
1617
echo "Options:"
1718
echo " -d: Downloads the Khiops tutorial repository. Implies -t. See also -r."
1819
echo " -t: Transform the Khiops Jupyter notebooks tutorials into reST."
19-
echo " -r: Set the Khiops tutorial repository. The default is"
20+
echo " -r: Set the Khiops tutorial repository URL. The default is"
2021
echo " '$DEFAULT_KHIOPS_TUTORIAL_REPO_URL'."
22+
echo " -g: Set the Khiops tutorial repository Git reference. The default is"
23+
echo " '$DEFAULT_KHIOPS_TUTORIAL_REPO_REF'."
2124
echo " -l: Directory of the local copy of the khiops tutorial repository. The default is"
2225
echo " '$DEFAULT_KHIOPS_TUTORIAL_DIR'."
2326
echo ""
@@ -29,17 +32,19 @@ exit_bad() {
2932
}
3033

3134
# Read command line arguments
32-
while getopts "dtr:l:" opt
35+
while getopts "dtrg:l:" opt
3336
do
3437
case "$opt" in
3538
d ) DOWNLOAD_REPO=true && TRANSFORM_NOTEBOOKS="true" ;;
3639
t ) TRANSFORM_NOTEBOOKS="true" ;;
3740
r ) KHIOPS_TUTORIAL_REPO_URL="$OPTARG" ;;
41+
g ) KHIOPS_TUTORIAL_REPO_REF="$OPTARG" ;;
3842
l ) KHIOPS_TUTORIAL_REPO_DIR="$OPTARG" ;;
3943
* ) exit_bad ;;
4044
esac
4145
done
4246
KHIOPS_TUTORIAL_REPO_URL="${KHIOPS_TUTORIAL_REPO_URL:-$DEFAULT_KHIOPS_TUTORIAL_REPO_URL}"
47+
KHIOPS_TUTORIAL_REPO_REF="${KHIOPS_TUTORIAL_REPO_REF:-$DEFAULT_KHIOPS_TUTORIAL_REPO_REF}"
4348
KHIOPS_TUTORIAL_REPO_DIR="${KHIOPS_TUTORIAL_REPO_DIR:-$DEFAULT_KHIOPS_TUTORIAL_DIR}"
4449

4550

@@ -69,10 +74,9 @@ done
6974
# Clone the Khiops tutorial repository
7075
if [[ $DOWNLOAD_REPO ]]
7176
then
72-
echo "Obtaining khiops-python-tutorial"
77+
echo "Obtaining khiops-python-tutorial revision $KHIOPS_TUTORIAL_REPO_REF"
7378
rm -rf "$KHIOPS_TUTORIAL_REPO_DIR"
74-
khiops_python_tutorial_repo_branch="main"
75-
git clone --depth 1 --branch="$khiops_python_tutorial_repo_branch" \
79+
git clone --depth 1 --branch="$KHIOPS_TUTORIAL_REPO_REF" \
7680
"$KHIOPS_TUTORIAL_REPO_URL" "$KHIOPS_TUTORIAL_REPO_DIR" \
7781
&& rm -rf "$KHIOPS_TUTORIAL_REPO_DIR/.git"
7882
fi

0 commit comments

Comments
 (0)