Skip to content

Commit db2b1ae

Browse files
committed
build(publish-docs): Add docs github action
1 parent 7753165 commit db2b1ae

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.github/workflows/publish-docs.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Publish Docs
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: [ '3.x' ]
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Configure git
15+
run: |
16+
git config --global user.name 'travis-ci'
17+
git config --global user.email 'travis@nowhere.edu'
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Get full Python version
24+
id: full-python-version
25+
shell: bash
26+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
27+
28+
- name: Install poetry
29+
run: |
30+
curl -O -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
31+
python get-poetry.py -y
32+
echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH"
33+
rm get-poetry.py
34+
35+
- name: Get poetry cache paths from config
36+
run: |
37+
echo ::set-env name=poetry_cache_dir::$(poetry config --list | sed -n 's/.*cache-dir = //p' | sed -e 's/^"//' -e 's/"$//')
38+
echo ::set-env name=poetry_virtualenvs_path::$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^"//' -e 's/"$//')
39+
40+
- name: Configure poetry
41+
shell: bash
42+
run: poetry config virtualenvs.in-project true
43+
44+
- name: Set up cache
45+
uses: actions/cache@v2
46+
id: cache
47+
with:
48+
path: |
49+
.venv
50+
{{ env.poetry_cache_dir }}
51+
{{ env.poetry_virtualenvs_path }}
52+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
53+
54+
- name: Ensure cache is healthy
55+
if: steps.cache.outputs.cache-hit == 'true'
56+
shell: bash
57+
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
58+
59+
- name: Upgrade pip
60+
shell: bash
61+
run: poetry run python -m pip install pip -U
62+
63+
- name: Install dependencies [w/ docs]
64+
run: poetry install --extras "docs lint"
65+
66+
- name: Build documentation
67+
run: |
68+
pushd docs; make SPHINXBUILD='poetry run sphinx-build' html; popd
69+
70+
- name: Push documentation to S3
71+
uses: jakejarvis/s3-sync-action@master
72+
with:
73+
args: --acl public-read --follow-symlinks --delete
74+
env:
75+
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
76+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
77+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
78+
AWS_REGION: 'us-west-1' # optional: defaults to us-east-1
79+
SOURCE_DIR: 'docs/_build/html' # optional: defaults to entire repository
80+
81+
- name: Generate list of changed files for CloudFront to invalidate
82+
run: |
83+
pushd docs/_build/html; FILES=$(find . -name \* -print | grep html | cut -c2- | sort | uniq | tr '\n' ' '); popd
84+
for file in $FILES; do
85+
echo $file
86+
# add bare directory to list of updated paths when we see index.html
87+
[[ "$file" == *"/index.html" ]] && echo $file | sed -e 's/\/index.html$/\//'
88+
done | sort | uniq | tr '\n' ' ' > .updated_files
89+
90+
- name: Invalidate on CloudFront
91+
uses: chetan/invalidate-cloudfront-action@master
92+
env:
93+
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION }}
94+
AWS_REGION: 'us-east-1'
95+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
96+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
97+
PATHS_FROM: .updated_files

0 commit comments

Comments
 (0)