Fetch full repo again #59
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: publish-doc | |
on: | |
push: | |
branches: | |
- 'master' | |
- 'docs-on-gh-pages' | |
tags: | |
- v*-* | |
workflow_dispatch: | |
concurrency: | |
group: pages | |
cancel-in-progress: true | |
jobs: | |
build-doc: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Need to full repo for getting all tags | |
- name: Check available tags | |
run: | | |
git for-each-ref --format "%(refname)" | |
- uses: cvmfs-contrib/github-action-cvmfs@v3 | |
- uses: aidasoft/run-lcg-view@v4 | |
with: | |
container: el9 | |
view-path: /cvmfs/sw-nightlies.hsf.org/key4hep | |
run: | | |
echo "::group::Install dependencies" | |
python3 -m pip install -r doc/requirements.txt | |
export PATH=/root/.local/bin:$PATH | |
# Newer versions of git are more cautious around the github runner | |
# environment and without this git rev-parse --show-cdup in pre-commit | |
# fails | |
git config --global --add safe.directory $(pwd) | |
echo -e "::endgroup::\n::group::Build podio" | |
cmake -B build . --install-prefix=$(pwd)/install \ | |
-GNinja -DENABLE_SIO=ON -DENABLE_RNTUPLE=ON \ | |
-DBUILD_TESTING=OFF \ | |
-DCMAKE_CXX_STANDARD=17 | |
cmake --build build --target install | |
export PYTHONPATH=$(pwd)/install/python:$PYTHONPATH | |
export LD_LIBRARY_PATH=$(pwd)/install/lib*/:$LD_LIBRARY_PATH | |
export ROOT_INCLUDE_PATH=$(pwd)/install/include | |
echo -e "::endgroup::\n::group::build doc" | |
export GIT_CURRENT_REF=${{ github.ref_name }} | |
# sphinx-build -M html doc doc_output | |
sphinx-multiversion doc doc_output | |
cp doc/aux/main_index_redirect.html doc_output/index.html | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: doc_output | |
publish-doc: | |
needs: build-doc | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: github-pages | |
path: doc_artifact | |
- name: Update documentation | |
run: | | |
tar -xvf doc_artifact/artifact.tar --directory . | |
rm -r doc_artifact | |
# If there are tags simply use the latest one via lexicographic sort | |
if ls -d v*/ > /dev/null 2>&1; then | |
latest_version=$(ls -d v*/ | tail -n1) | |
sed -i s'/__LATEST__/${latest_version}/g' index.html | |
else | |
# Fall back to whatever we just built now | |
sed -i s'/__LATEST__/${{ github.ref_name }}/g' index.html | |
fi | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git init | |
git config --global user.email ${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com | |
git config --global user.name ${GITHUB_ACTOR} | |
git remote add upstream https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
git checkout -b gh-pages | |
touch .nojekyll | |
git add .nojekyll | |
git commit -m "Add .nojekyll for ${GITHUB_SHA}" | |
git add -A . | |
git commit -m "Rebuild page at ${GITHUB_SHA}" | |
git push -f upstream gh-pages:gh-pages |