Skip to content

github-actions(deps): bump actions/checkout from 3 to 4 #398

github-actions(deps): bump actions/checkout from 3 to 4

github-actions(deps): bump actions/checkout from 3 to 4 #398

Workflow file for this run

name: Docs CI
on:
push:
branches-ignore:
- 'dependabot/**'
tags:
- 'v*'
pull_request:
jobs:
docs-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
# Matrix setup is a hacky way to include 'base' build in pull requests
# The entire matrix is set up and 'base' builds are pruned based
# on event name and final configuration (ubuntu, python3.7).
matrix:
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
python-architecture: ['x64']
os: [ubuntu-latest]
event:
- ${{ github.event_name }}
outputs:
on_main: ${{ steps.on_main.outputs.on-branch }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
# need history and tags for versioneer
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.0.0
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.python-architecture }}
- name: Get pip cache location
shell: bash
id: pip_cache
run: |
python -m pip install -U pip
python -m pip --version
echo ::set-output name=pip_cache_dir::$(python -m pip cache dir)
- name: Wheels cache
uses: actions/cache@v3.3.1
with:
path: ${{ steps.pip_cache.outputs.pip_cache_dir }}/wheels
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-v2-${{ github.sha }}
restore-keys: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-v2
- name: Install local, editable package
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r docs_requirements.txt && python -m pip install -e .
- name: Build Documentation
run: make -C docs html
- name: Upload Documentation
uses: actions/upload-artifact@v3
with:
name: Documentation-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.python-architecture }}
retention-days: 1
path: docs/_build/html
- name: Check if on main
if: ${{ github.event_name == 'push' }}
id: on_main
uses: ./.github/actions/on-branch
with:
branch: main
docs-deploy:
strategy:
fail-fast: false
matrix:
python-version: [3.7]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
needs: [docs-build]
if: github.event_name == 'push' &&
(github.ref == 'refs/heads/main' ||
(startsWith(github.ref, 'refs/tags/') && contains(needs.*.outputs.on_main, 'main'))
)
steps:
- name: Checkout docs
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Fetch tags
run: git fetch origin +refs/tags/*:refs/tags/*
- name: Download branch docs
uses: actions/download-artifact@v3
with:
name: Documentation-${{ matrix.os }}-${{ matrix.python-version }}-x64
path: _built_docs/${{ github.ref }}
if: github.ref == 'refs/heads/main'
- name: Update branch docs
shell: bash
run: |
mkdir -p branch
rm -rf "branch/${GITHUB_REF##*/}"
mv -f "_built_docs/${GITHUB_REF}" branch/
if: github.ref == 'refs/heads/main'
- name: Download main docs
uses: actions/download-artifact@v3
with:
name: Documentation-${{ matrix.os }}-${{ matrix.python-version }}-x64
path: _built_docs/${{ github.ref }}
if: startsWith(github.ref, 'refs/tags/') && contains(needs.*.outputs.on_main, 'main')
- name: Update main docs
shell: bash
run: |
mkdir -p tag
# Save docs to tags dir for this tag
tag_name=$(echo "${GITHUB_REF}" | sed -r 's;refs/tags/(.*?)$;\1;')
cp -r "_built_docs/${GITHUB_REF}/" "tag/$tag_name/"
# don't update main docs if tag is old
if [ $(git tag --contains "$tag_name" | wc -l) -lt 2 ]; then
cp -r "_built_docs/${GITHUB_REF}/"* ./
fi
rm -rf "_built_docs/"
if: startsWith(github.ref, 'refs/tags/') && contains(needs.*.outputs.on_main, 'main')
- name: Commit documentation changes
run: |
git add .
git config --local user.name "Documentation Bot"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "Docs changes for $GITHUB_REF $GITHUB_SHA" || true
git push