Skip to content

Improve deploy of docs in gh-pages #46

Improve deploy of docs in gh-pages

Improve deploy of docs in gh-pages #46

Workflow file for this run

name: Build and Deploy Docs
on:
push:
branches:
- main
- dev
tags:
- '*'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Install Dependencies
run: |
pip install poetry
poetry install
- name: Build Docs with sphinx-multiversion
run: |
poetry run sphinx-multiversion docs docs/_build/html
- name: Create Redirection HTML
run: |
echo '<meta http-equiv="refresh" content="0; URL='https://saezlab.github.io/corneto/main'" />' > docs/_build/html/index.html
- name: Prepare Deployment
run: |
touch ./docs/_build/html/.nojekyll
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Deploy to GitHub Pages
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git fetch origin gh-pages
git checkout gh-pages || git checkout --orphan gh-pages
# Get the name of the branch that triggered the workflow
BRANCH_NAME=${GITHUB_REF#refs/heads/}
echo "Deploying documentation for branch: $BRANCH_NAME"
# Removing old files
rm -rf "./$BRANCH_NAME"
mkdir -p "./$BRANCH_NAME"
# Copying new files
cp -r "docs/_build/html/$BRANCH_NAME/." "./$BRANCH_NAME/"
# Adding changes to git
git add .
git commit -m "Update docs for branch $BRANCH_NAME"
git push -u origin gh-pages