Update README.md #115
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | | |
# Create a temporary directory | |
TEMP_DIR=$(mktemp -d) | |
chmod 777 $TEMP_DIR | |
echo "TEMP_DIR=$TEMP_DIR" >> $GITHUB_ENV | |
echo "Temporary directory is $TEMP_DIR" | |
poetry run sphinx-multiversion docs $TEMP_DIR | |
touch $TEMP_DIR/.nojekyll | |
echo '<meta http-equiv="refresh" content="0; URL='https://saezlab.github.io/corneto/main'" />' > $TEMP_DIR/index.html | |
- name: Deploy to GitHub Pages | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
# 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 | |
echo "Removing current folder content: $BRANCH_NAME" | |
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 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} |