Skip to content

Commit 86e63c1

Browse files
committed
👷 Add GitHub Actions to Build Docs, Test, and Publish
1 parent 2945723 commit 86e63c1

File tree

3 files changed

+143
-0
lines changed

3 files changed

+143
-0
lines changed

.github/workflows/build-docs.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build Docs
2+
on:
3+
push:
4+
pull_request:
5+
types: [opened, synchronize]
6+
jobs:
7+
build-docs:
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- name: Dump GitHub context
11+
env:
12+
GITHUB_CONTEXT: ${{ toJson(github) }}
13+
run: echo "$GITHUB_CONTEXT"
14+
- uses: actions/checkout@v2
15+
- name: Set up Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: "3.7"
19+
- uses: actions/cache@v2
20+
id: cache
21+
with:
22+
path: ${{ env.pythonLocation }}
23+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-docs
24+
- name: Install poetry
25+
if: steps.cache.outputs.cache-hit != 'true'
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install "poetry>=1.2.0a1"
29+
python -m poetry plugin add poetry-version-plugin
30+
- name: Configure poetry
31+
run: python -m poetry config virtualenvs.in-project true
32+
- name: Ensure cache is healthy
33+
if: steps.cache.outputs.cache-hit == 'true'
34+
run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
35+
- name: Install Dependencies
36+
if: steps.cache.outputs.cache-hit != 'true'
37+
run: python -m poetry install
38+
- name: Install Material for MkDocs Insiders
39+
if: github.event.pull_request.head.repo.fork == false && steps.cache.outputs.cache-hit != 'true'
40+
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
41+
- name: Build Docs
42+
run: python3.7 -m mkdocs build
43+
- name: Zip docs
44+
run: bash ./scripts/zip-docs.sh
45+
- uses: actions/upload-artifact@v2
46+
with:
47+
name: docs-zip
48+
path: ./docs.zip
49+
- name: Deploy to Netlify
50+
uses: nwtgck/[email protected]
51+
with:
52+
publish-dir: './site'
53+
production-branch: main
54+
github-token: ${{ secrets.GITHUB_TOKEN }}
55+
enable-commit-comment: false
56+
env:
57+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
58+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

.github/workflows/publish.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up Python
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: "3.7"
17+
- uses: actions/cache@v2
18+
id: cache
19+
with:
20+
path: ${{ env.pythonLocation }}
21+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test
22+
- name: Install poetry
23+
if: steps.cache.outputs.cache-hit != 'true'
24+
run: |
25+
python -m pip install --upgrade pip
26+
python -m pip install "poetry>=1.2.0a1"
27+
python -m poetry plugin add poetry-version-plugin
28+
- name: Configure poetry
29+
run: python -m poetry config virtualenvs.in-project true
30+
- name: Ensure cache is healthy
31+
if: steps.cache.outputs.cache-hit == 'true'
32+
run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
33+
- name: Install Dependencies
34+
if: steps.cache.outputs.cache-hit != 'true'
35+
run: python -m poetry install
36+
- name: Publish
37+
env:
38+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
39+
run: |
40+
python -m poetry config pypi-token.pypi $PYPI_TOKEN
41+
bash scripts/publish.sh

.github/workflows/test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, synchronize]
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-20.04
11+
strategy:
12+
matrix:
13+
python-version: [3.6, 3.7, 3.8, 3.9]
14+
fail-fast: false
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- uses: actions/cache@v2
23+
id: cache
24+
with:
25+
path: ${{ env.pythonLocation }}
26+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test
27+
- name: Install poetry
28+
if: steps.cache.outputs.cache-hit != 'true'
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install "poetry>=1.2.0a1"
32+
python -m poetry plugin add poetry-version-plugin
33+
- name: Configure poetry
34+
run: python -m poetry config virtualenvs.in-project true
35+
- name: Ensure cache is healthy
36+
if: steps.cache.outputs.cache-hit == 'true'
37+
run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
38+
- name: Install Dependencies
39+
if: steps.cache.outputs.cache-hit != 'true'
40+
run: python -m poetry install
41+
- name: Test
42+
run: bash scripts/test.sh
43+
- name: Upload coverage
44+
uses: codecov/codecov-action@v1

0 commit comments

Comments
 (0)