Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a deploy action #85

Merged
merged 19 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 62 additions & 92 deletions .github/workflows/doc-build.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,65 @@
---
# Workflow to build the documentation.
name: Build documentation
name: Build and Deploy Sphinx Docs

on:
push:
branches:
- main
pull_request:
branches:
- '*'
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]
build:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4

# Step 2: Set up Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11

# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install -e ".[doc, jax, test]"

# Step 4: Build Sphinx documentation
- name: Build Sphinx documentation
working-directory: doc
run: |
python -m sphinx -b html . _build/html

# Step 5: Upload Sphinx docs as an artifact
- name: Upload Sphinx docs artifact
uses: actions/upload-artifact@v4
with:
name: sphinx-docs
path: doc/_build/html

deploy:
# Avoid running this job on a fork
if: github.repository == 'parietal-INRIA/fmralign'
needs: build
runs-on: ubuntu-latest

# 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

# Push the HTML to github-pages
- name: GitHub Pages action
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: doc/_build/html
steps:
# Step 6: Download Sphinx docs artifact
- name: Download Sphinx docs artifact
uses: actions/download-artifact@v4
with:
name: sphinx-docs
path: doc/_build/html/
# Step 7: Deploy to GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: doc/_build/html
Loading