diff --git a/.github/workflows/gh-ci.yaml b/.github/workflows/gh-ci.yaml index a9fee810031..679dd97ec5f 100644 --- a/.github/workflows/gh-ci.yaml +++ b/.github/workflows/gh-ci.yaml @@ -19,6 +19,7 @@ env: MDA_PIP_MIN_DEPS: 'coveralls coverage<5 pytest-cov pytest-xdist' MDA_PIP_EXTRA_DEPS: 'duecredit parmed' + jobs: main_tests: if: "github.repository == 'MDAnalysis/mdanalysis'" @@ -211,9 +212,57 @@ jobs: - name: deploy_docs if: github.event_name != 'pull_request' + env: + GH_USER: github-actions + GH_EMAIL: "github-action@users.noreply.github.com" + GH_REPOSITORY: "github.com/${{ github.repository }}.git" + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + URL: https://docs.mdanalysis.org + run: | - # place the deploy call here - echo "Oh, maple syrup roast parsnips [Richard Gowers]" + # set up environment variables + # cannot execute bash to make variables in env section + # export URL for the Python script $UPDATE_JSON + export URL + export VERSION=$(cd package/MDAnalysis; python -c 'import version; print(version.__version__)') + UPDATE_JSON=$(pwd)/maintainer/update_json_stubs_sitemap.py + BRANCH="${GITHUB_REF#refs/heads/}" + + # the below turns off non-blocking as it causes large writes to stdout to fail + # (see https://github.com/travis-ci/travis-ci/issues/4704) + # commented out as this is not a problem with gh-actions + # python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);' + cd package/doc/html/html + + # move docs into version subfolder + mkdir ../${VERSION} && mv * ../${VERSION} && mv ../${VERSION} $VERSION + + # set up git + REV=$(git rev-parse --short HEAD) + git init + git config user.name $GH_USER + git config user.email $GH_EMAIL + git remote add upstream "https://${GH_USER}:${GH_TOKEN}@${GH_REPOSITORY}" + git fetch --depth 50 upstream $BRANCH gh-pages + git reset upstream/gh-pages + + # redirects and copies + mkdir latest + python $UPDATE_JSON + touch . + touch .nojekyll + + git add -A ${VERSION}/ + git add .nojekyll versions.json *.xml *.html index.html latest + + for dirname in dev stable documentation_pages ; do + if [ -d $dirname ]; then git add $dirname; fi + done + + # check for anything to commit + # https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommited-changes + git diff-index --quiet HEAD -- || git commit -m "rebuilt html docs for version ${VERSION} from branch ${BRANCH} with sphinx at ${REV}" + git push -q upstream HEAD:gh-pages pylint_check: diff --git a/maintainer/deploy_docs_via_travis.sh b/maintainer/deploy_docs_via_travis.sh deleted file mode 100644 index 52c613e6b89..00000000000 --- a/maintainer/deploy_docs_via_travis.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# Deploying docs from travis-ci. -# See https://github.com/MDAnalysis/mdanalysis/issues/386 -# Script based on https://github.com/steveklabnik/automatically_update_github_pages_with_travis_example - -# Run this script from the top-level of the checked out git -# repository. A github OAuth token must be available in the evironment -# variable GH_TOKEN and is set up through the .travis.yml -# env:global:secure parameter (encrypted with travis-ci's public key)/ -# -# Additional environment variables set in .travis.yml -# GH_REPOSITORY repo to full from and push to -# GH_DOC_BRANCH branch from which the docs are built -# GIT_CI_USER name of the user to push docs as -# GIT_CI_EMAIL email of the user to push docs as -# MDA_DOCDIR path to the docdir from top of repo -# MAINTAIN_DIR path to maintainer/ -# VERSION version of MDAnalysis -# -# NOTE: If any of these environment variables are not set or -# empty then the script will exit with and error (-o nounset). - -set -o errexit -o nounset - -function die () { - local msg="$1" err=${2:-1} - echo "ERROR: $msg [$err]" - exit $err -} - -rev=$(git rev-parse --short HEAD) - -# the following tests should be superfluous because of -o nounset -test -n "${GH_TOKEN}" || die "GH_TOKEN is empty: need OAuth GitHub token to continue" 100 -test -n "${GH_REPOSITORY}" || die "GH_REPOSITORY must be set in .travis.yml" 100 -test -n "${MDA_DOCDIR}" || die "MDA_DOCDIR must be set in .travis.yml" 100 -test -n "${MAINTAIN_DIR}" || die "MAINTAIN_DIR must be set in .travis.yml" 100 -test -n "${VERSION}" || die "VERSION must be set in .travis.yml" 100 - - -cd ${MDA_DOCDIR} || die "Failed to 'cd ${MDA_DOCDIR}'. Run from the top level of the repository" - -# move into $version subdirectory -mkdir ../${VERSION} && mv * ../${VERSION} - -git init -git config user.name "${GIT_CI_USER}" -git config user.email "${GIT_CI_EMAIL}" - -mv ../${VERSION} $VERSION - -git remote add upstream "https://${GH_TOKEN}@${GH_REPOSITORY}" -git fetch --depth 50 upstream ${GH_DOC_BRANCH} gh-pages -git reset upstream/gh-pages - -# === REDIRECTS AND COPIES ==== -# home (index.html) redirects to stable/ -# latest (latest/index.html) redirects to most recent release -# dev/ is a copy of the dev docs with the highest number (so 2.0.0-dev instead of 1.0.1-dev) -# stable/ is a copy of the release docs with the highest number -mkdir latest -export URL="https://docs.mdanalysis.org" -python ${MAINTAIN_DIR}/update_json_stubs_sitemap.py -touch . -touch .nojekyll - -git add -A ${VERSION}/ -git add .nojekyll versions.json -git add index.html latest - -for dirname in dev stable documentation_pages ; do - if [ -d $dirname ]; then git add $dirname; fi -done - -git add *.xml *.html - -# check for anything to commit -# https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommited-changes -git diff-index --quiet HEAD -- || git commit -m "rebuilt html docs for version ${VERSION} from branch ${GH_DOC_BRANCH} with sphinx at ${rev}" -git push -q upstream HEAD:gh-pages - -