-
Notifications
You must be signed in to change notification settings - Fork 3
76 lines (61 loc) · 2.2 KB
/
deploy-docs.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
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 "[email protected]"
git config --local user.name "GitHub Action"
- name: Deploy to GitHub Pages
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Create a temporary directory
TEMP_DIR=$(mktemp -d)
echo "Temporary directory is $TEMP_DIR"
# Build and prepare all the files first
mkdir -p "$TEMP_DIR/$BRANCH_NAME"
cp -r "docs/_build/html/." "$TEMP_DIR/$BRANCH_NAME/"
# Now checkout to gh-pages
git fetch origin gh-pages
git checkout gh-pages || git checkout --orphan gh-pages
# Clean existing files for the branch and copy new ones
rm -rf "./$BRANCH_NAME"
cp -r "$TEMP_DIR/$BRANCH_NAME/." "./$BRANCH_NAME/"
# Adding changes to git
git add .
git commit -m "Update docs for branch $BRANCH_NAME" --allow-empty
git push -u origin gh-pages
# Optionally, remove the temporary directory (not necessary on CI environments)
# rm -rf "$TEMP_DIR"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}