-
Notifications
You must be signed in to change notification settings - Fork 7
120 lines (115 loc) · 4.31 KB
/
doc-build.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
---
# Workflow to build the documentation.
name: Build documentation
on:
push:
branches:
- main
pull_request:
branches:
- '*'
jobs:
# Steps to build the documentation.
build_docs:
# This prevents this workflow from running on a fork.
if: github.repository == 'parietal-INRIA/fmralign'
runs-on: ubuntu-latest
timeout-minutes: 360
defaults:
run:
shell: bash -el {0}
steps:
- name: Source caching
uses: actions/cache@v3
with:
path: .git
key: source-cache-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
source-cache-${{ runner.os }}
- name: Checkout fmralign
uses: actions/checkout@v3
with:
# If pull request, checkout HEAD commit with all commit history
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Complete checkout
run: |
set -x
if ! git remote -v | grep upstream; then
git remote add upstream https://github.com/parietal-INRIA/fmralign.git
fi
git fetch upstream
- name: Merge with upstream
run: |
set -x
echo $(git log -1 --pretty=%B) | tee gitlog.txt
echo "gitlog.txt = $(cat gitlog.txt)"
echo $GITHUB_REF_NAME | tee merge.txt
if [ "$GITHUB_REF_NAME" != "main" ]; then
echo "Merging $(cat merge.txt)";
git pull --ff-only upstream "refs/pull/$(cat merge.txt)";
fi
# Set up environment
- name: Install apt packages
run: |
sudo -E apt-get -yq update
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install \
dvipng texlive-latex-base texlive-latex-extra
- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: true
activate-environment: ''
miniconda-version: latest
channels: conda-forge
- name: Install packages in conda env
run: |
conda init bash
echo "conda version = $(conda --version)"
conda create -n testenv
conda install -n testenv -yq python=3.9
source activate testenv
python -m pip install --user --upgrade --progress-bar off pip
# See pyproject.toml for dependency group options
python -m pip install .[jax,test,doc]
# Run the doc build.
- name: Build docs
run: |
source activate testenv
echo "Conda active env = $CONDA_DEFAULT_ENV";
cd doc;
set -o pipefail;
make html | tee log.txt;
- name: Upload documentation
uses: actions/upload-artifact@v3
with:
name: doc
path: doc/_build/html
# Deploy the documentation to GitHub Pages.
deploy_docs:
if: github.repository == 'parietal-INRIA/fmralign'
needs: build_docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: DocHTML
path: doc/_build/html/
- name: Commit to documentation branch
run: |
git clone --depth 1 https://github.com/${{ github.repository }}.git --branch gh-pages --single-branch gh-pages
cp -r doc/_build/html/* gh-pages/
cd gh-pages
touch .nojekyll
git config --local user.email "[email protected]"
git config --local user.name "fmralign GitHub Action"
git add .
git commit -m "Update documentation" -a || true
- name: Push changes
uses: ad-m/[email protected]
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}