|
1 | | -name: "DOCUMENTATION" |
| 1 | +# Workflow to build doc, upload it as artifact, and deploy it for the |
| 2 | +# master, main and dev branches. |
| 3 | +# |
| 4 | +# To run this check locally from the `doc` folder: |
| 5 | +# |
| 6 | +# .. code-block:: bash |
| 7 | +# |
| 8 | +# $ sphinxdoc -v 2 -p $MODULE_DIR -n brainprep -o $MODULE_DIR/doc |
| 9 | +# $ cd $MODULE_DIR/doc |
| 10 | +# $ make html-strict |
| 11 | +### |
| 12 | +name: "DocumentationBuilder" |
2 | 13 |
|
3 | 14 | on: |
4 | 15 | push: |
5 | 16 | branches: |
6 | 17 | - "master" |
| 18 | + - "main" |
| 19 | + - "dev" |
7 | 20 | pull_request: |
8 | 21 | branches: |
9 | 22 | - "*" |
| 23 | + workflow_dispatch: |
| 24 | + |
| 25 | +env: |
| 26 | + MIN_PYTHON_VERSION: "3.12" |
10 | 27 |
|
11 | 28 | jobs: |
12 | 29 |
|
13 | 30 | build_and_deploy: |
14 | 31 |
|
15 | | - runs-on: ${{ matrix.os }} |
16 | | - if: ${{ github.ref == 'refs/heads/master' }} |
| 32 | + runs-on: "ubuntu-latest" |
17 | 33 | strategy: |
18 | 34 | fail-fast: false |
19 | | - matrix: |
20 | | - os: [ubuntu-latest] |
21 | | - python-version: [3.12] |
| 35 | + env: |
| 36 | + FREESURFER_HOME: "/freesurfer/home" |
22 | 37 |
|
23 | 38 | permissions: |
24 | 39 | contents: write |
25 | 40 |
|
26 | 41 | steps: |
| 42 | + - name: Extract branch name |
| 43 | + id: extract-branch |
| 44 | + shell: bash |
| 45 | + run: echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT |
| 46 | + - name: Identify deploy type |
| 47 | + id: deploy-type |
| 48 | + run: | |
| 49 | + if ${{ github.ref == 'refs/heads/master' || |
| 50 | + github.ref == 'refs/heads/main' }}; then |
| 51 | + echo "DEPLOY_TYPE=stable" >> $GITHUB_OUTPUT |
| 52 | + elif ${{ github.ref == 'refs/heads/dev' }}; then |
| 53 | + echo "DEPLOY_TYPE=dev" >> $GITHUB_OUTPUT |
| 54 | + else |
| 55 | + echo "DEPLOY_TYPE=pr" >> $GITHUB_OUTPUT |
| 56 | + fi |
27 | 57 | - name: Checkout repository |
28 | | - uses: actions/checkout@v4 |
| 58 | + uses: actions/checkout@v5 |
29 | 59 | with: |
30 | 60 | fetch-depth: 0 |
31 | | - - name: Set up Python ${{ matrix.python-version }} |
32 | | - uses: actions/setup-python@v5 |
| 61 | + - name: Set up Python |
| 62 | + uses: actions/setup-python@v6 |
33 | 63 | with: |
34 | | - python-version: ${{ matrix.python-version }} |
35 | | - - name: Install dependencies |
| 64 | + python-version: ${{ env.MIN_PYTHON_VERSION }} |
| 65 | + cache: "pip" |
| 66 | + - name: Install Python dependencies |
36 | 67 | run: | |
37 | 68 | python -m pip install --upgrade pip |
38 | | - python -m pip install --progress-bar off . |
39 | | - python -m pip install git+https://github.com/AGrigis/pysphinxdoc.git |
40 | | - python -m pip install requests "scipy<=1.15" statsmodels |
41 | | - python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu |
42 | | - python -m pip install git+https://github.com/neurospin-deepinsight/brainrise.git |
| 69 | + python -m pip install --progress-bar off ".[ci,doc]" |
| 70 | + - name: Install apt packages |
| 71 | + uses: awalsh128/cache-apt-pkgs-action@latest |
| 72 | + with: |
| 73 | + packages: dvipng texlive-latex-base texlive-latex-extra build-essential |
| 74 | + version: 1.0 |
| 75 | + - name: Install documentation resources |
| 76 | + run: | |
| 77 | + DIR=$(pwd) |
| 78 | + which python |
| 79 | + sphinxdoc -v 2 -p $DIR -n brainprep -o $DIR/doc |
43 | 80 | - name: Compute documentation |
44 | 81 | run: | |
45 | | - mkdir -p tmp/doc |
46 | | - sphinxdoc -v 2 -p . -n brainprep -o tmp/doc |
47 | | - cd tmp/doc |
48 | | - make raw-html |
49 | | - ls source/_static |
50 | | - ls build/html/_static |
51 | | - cp -r source/_static/* build/html/_static |
52 | | - cd ../.. |
| 82 | + DIR=$(pwd) |
| 83 | + cd $DIR/doc |
| 84 | + echo "Documentation folder: $DIR/doc" |
| 85 | + make html-strict |
| 86 | + cd $DIR |
53 | 87 | - name: Upload documentation as an artifact |
54 | 88 | uses: actions/upload-artifact@v4 |
| 89 | + env: |
| 90 | + DEPLOY_TYPE: ${{ steps.deploy-type.outputs.DEPLOY_TYPE }} |
55 | 91 | with: |
56 | | - name: html-documentation |
57 | | - retention-days: 15 |
| 92 | + name: doc-${{ env.DEPLOY_TYPE }} |
| 93 | + retention-days: 1 |
58 | 94 | path: | |
59 | | - tmp/doc/build/html |
| 95 | + doc/_build/html |
60 | 96 | - name: Deploy |
| 97 | + env: |
| 98 | + DEPLOY_TYPE: ${{ steps.deploy-type.outputs.DEPLOY_TYPE }} |
| 99 | + if: env.DEPLOY_TYPE != 'pr' |
61 | 100 | uses: peaceiris/actions-gh-pages@v4 |
62 | 101 | with: |
63 | 102 | github_token: ${{ secrets.GITHUB_TOKEN }} |
64 | | - publish_dir: tmp/doc/build/html |
65 | | - |
66 | | - build: |
67 | | - |
68 | | - runs-on: ${{ matrix.os }} |
69 | | - if: ${{ github.ref != 'refs/heads/master' }} |
70 | | - strategy: |
71 | | - fail-fast: false |
72 | | - matrix: |
73 | | - os: [ubuntu-latest] |
74 | | - python-version: [3.12] |
75 | | - |
76 | | - permissions: |
77 | | - contents: write |
78 | | - |
79 | | - steps: |
80 | | - - name: Checkout repository |
81 | | - uses: actions/checkout@v4 |
82 | | - with: |
83 | | - fetch-depth: 0 |
84 | | - - name: Set up Python ${{ matrix.python-version }} |
85 | | - uses: actions/setup-python@v5 |
86 | | - with: |
87 | | - python-version: ${{ matrix.python-version }} |
88 | | - - name: Install dependencies |
89 | | - run: | |
90 | | - python -m pip install --upgrade pip |
91 | | - python -m pip install --progress-bar off . |
92 | | - python -m pip install git+https://github.com/AGrigis/pysphinxdoc.git |
93 | | - python -m pip install requests "scipy<=1.15" statsmodels |
94 | | - python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu |
95 | | - python -m pip install git+https://github.com/neurospin-deepinsight/brainrise.git |
96 | | - - name: Compute documentation |
97 | | - run: | |
98 | | - mkdir -p tmp/doc |
99 | | - sphinxdoc -v 2 -p . -n brainprep -o tmp/doc |
100 | | - cd tmp/doc |
101 | | - make raw-html |
102 | | - ls source/_static |
103 | | - ls build/html/_static |
104 | | - cp -r source/_static/* build/html/_static |
105 | | - cd ../.. |
| 103 | + publish_dir: doc/_build/html |
| 104 | + destination_dir: ./${{ env.DEPLOY_TYPE }} |
0 commit comments