Skip to content

Commit 53d75a5

Browse files
authored
Merge pull request #748 from effigies/mnt/1.3.x-update
MNT: Update docs and GitHub actions config from master in LTS branch
2 parents c8c2729 + b280473 commit 53d75a5

File tree

10 files changed

+379
-643
lines changed

10 files changed

+379
-643
lines changed

.github/workflows/docs-build-pr.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
name: Build docs
3+
4+
on:
5+
pull_request:
6+
branches: [ master, 'maint/*' ]
7+
8+
jobs:
9+
build:
10+
if: "(github.repository_owner != 'nipreps') && !contains(github.event.head_commit.message, '[skip ci]')"
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Determine current branch/tag name
19+
run: |
20+
if [[ "$GITHUB_REF" == refs/pull/* ]]; then
21+
CURBRANCH=${GITHUB_REF%/*}
22+
CURBRANCH=${CURBRANCH##*/}
23+
elif [[ "$GITHUB_REF" == refs/heads/* ]]; then
24+
CURBRANCH=${GITHUB_REF##*/}
25+
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
26+
echo "This build should not be picking up a tag, cancelling."
27+
exit 1
28+
fi
29+
30+
# Remove forward slashes
31+
CURBRANCH=$( echo $CURBRANCH | sed 's+/+_+g' )
32+
echo "Building branch/tag ${CURBRANCH:-<unkwown>}, from git ref <$GITHUB_REF>"
33+
echo "CURBRANCH=${CURBRANCH}" >> ${GITHUB_ENV}
34+
35+
- name: Install GraphViz
36+
run: |
37+
sudo apt-get update -y
38+
sudo apt-get install -y --no-install-recommends graphviz
39+
40+
- name: Install dependencies
41+
run: |
42+
pip install -r docs/requirements.txt
43+
44+
- name: Build docs
45+
run: |
46+
make -C docs/ SPHINXOPTS="-W" BUILDDIR="$HOME/docs" OUTDIR="${CURBRANCH:-html}" html
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
name: Build & update docs
3+
4+
on:
5+
push:
6+
branches: [ 'doc/*', 'docs/*', master, "maint/*" ]
7+
tags: [ '*' ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
ssh-key: "${{ secrets.NIPREPS_DEPLOY }}"
17+
fetch-depth: 0
18+
19+
- name: Determine current branch/tag name & set-up git author
20+
run: |
21+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
22+
CURBRANCH=${GITHUB_REF##*/}
23+
elif [[ "$GITHUB_REF" == refs/pull/* ]]; then
24+
CURBRANCH=${GITHUB_REF%/*}
25+
CURBRANCH=${CURBRANCH##*/}
26+
elif [[ "$GITHUB_REF" == refs/heads/* ]]; then
27+
CURBRANCH=${GITHUB_REF##*/}
28+
fi
29+
30+
# Remove forward slashes
31+
CURBRANCH=$( echo $CURBRANCH | sed 's+/+_+g' )
32+
echo "Building branch/tag ${CURBRANCH:-<unkwown>}, from git ref <$GITHUB_REF>"
33+
echo "CURBRANCH=${CURBRANCH}" >> ${GITHUB_ENV}
34+
35+
# Pacify git if we were to commit something
36+
git config user.email "[email protected]"
37+
git config user.name "NiPreps Bot"
38+
- name: Install GraphViz
39+
run: |
40+
sudo apt-get update -y
41+
sudo apt-get install -y --no-install-recommends graphviz
42+
43+
- name: Install dependencies
44+
run: |
45+
pip install -r docs/requirements.txt
46+
47+
- name: Build docs
48+
run: |
49+
make -C docs/ SPHINXOPTS="-W" BUILDDIR="$HOME/docs" OUTDIR="${CURBRANCH:-html}" html
50+
51+
- name: Push created tag to gh-pages
52+
if: startsWith(github.ref, 'refs/tags/')
53+
run: |
54+
MAJOR_MINOR=${CURBRANCH%.*}
55+
if [[ "${MAJOR_MINOR}" == "" ]]; then
56+
echo "Could not identify release series"
57+
exit 1
58+
fi
59+
git checkout -b gh-pages origin/gh-pages
60+
git rm -r ${MAJOR_MINOR}/ || true
61+
# It is fundamental that the directory does not exist at all.
62+
rm -rf ${MAJOR_MINOR}
63+
cp -r $HOME/docs/$CURBRANCH $PWD/${MAJOR_MINOR}
64+
git add ${MAJOR_MINOR}
65+
python -c "from pathlib import Path; import json; f=Path('versions.json'); d=json.loads(f.read_text()); d['tags'].append(\"${MAJOR_MINOR}\"); d['tags'] = list(sorted(set(d['tags']))); f.write_text(json.dumps(d, indent=4)); print('Updated versions.json')"
66+
git add versions.json
67+
git commit -m "rel(${CURBRANCH}): Update docs of ${MAJOR_MINOR} series" || true
68+
git push
69+
70+
- name: Push "master" docs to gh-pages after a PR is merged
71+
if: github.ref == 'refs/heads/master'
72+
run: |
73+
if [[ "${CURBRANCH}" != "master" ]]; then
74+
echo "$CURBRANCH is not the default development branch"
75+
exit 1
76+
fi
77+
git checkout -b gh-pages origin/gh-pages
78+
git rm -r master/ || true
79+
# It is fundamental that the directory does not exist at all.
80+
rm -rf master
81+
cp -r $HOME/docs/$CURBRANCH $PWD/master
82+
git add master
83+
git commit -am "docs(master): Update docs of development line" || true
84+
git push

0 commit comments

Comments
 (0)