Skip to content

Commit

Permalink
Add GitHub workflow for deploying docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdewar committed Aug 6, 2024
1 parent 51419aa commit e215b88
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"{% if cookiecutter.packaging != 'pip-tools' %}dev-requirements.txt{% endif %}",
"{% if cookiecutter.packaging != 'pip-tools' or not cookiecutter.mkdocs %}doc-requirements.txt{% endif %}",
"{% if not cookiecutter.mkdocs %}docs{% endif %}",
"{% if not cookiecutter.mkdocs %}.github/workflows/docs.yml{% endif %}",
"README.*.jinja",
)

Expand Down
61 changes: 61 additions & 0 deletions {{ cookiecutter.project_slug }}/.github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Deploy to GitHub Pages

on:
push:
branches: [main]
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
{%- if cookiecutter.packaging == 'poetry' %}
- name: Install Poetry
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: 1.8.3
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: poetry
- name: Install dependencies
run: poetry install
- name: Build docs with MkDocs
run: poetry run mkdocs build
{%- elif cookiecutter.packaging == 'pip-tools' %}
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: Install dependencies
run: pip install .[doc]
- name: Build docs with MkDocs
run: mkdocs build
{%- endif %}
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

0 comments on commit e215b88

Please sign in to comment.