From 2a35f29ad1fed0460a9d010974bdc2a5355f6f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Adamczak?= Date: Tue, 9 Jan 2024 02:02:06 +0100 Subject: [PATCH] Deploy docs to GitHub Pages via GitHub Actions --- .github/workflows/docs.yml | 63 ++++++++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 + noxfile.py | 13 ++++++++ 3 files changed, 77 insertions(+) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..f4ab8d3 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,63 @@ +--- +name: "Docs" + +on: + release: + types: ["published"] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "deploy-docs" + cancel-in-progress: false + +env: + FORCE_COLOR: "1" + PIP_DISABLE_PIP_VERSION_CHECK: "1" + PYTHON_VERSION: "3.11" + +jobs: + build: + name: "Build docs" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout code" + uses: "actions/checkout@v4" + + - name: "Setup Python ${{ env.PYTHON_VERSION }}" + uses: "actions/setup-python@v4" + with: + python-version: "${{ env.PYTHON_VERSION }}" + cache: "pip" + cache-dependency-path: "requirements/*.txt" + + - name: "Update pip and install Nox" + run: "python -m pip install pip nox -c requirements/constraints.txt" + + - name: "Setup GitHub Pages" + uses: "actions/configure-pages@v4" + + - name: "Build docs with 'docs' Nox session" + run: "nox -s docs" + + - name: "Upload artifact" + uses: "actions/upload-pages-artifact@v3" + with: + path: "site/" + + deploy: + name: "Deploy docs to GitHub Pages" + runs-on: "ubuntu-latest" + needs: + - "build" + environment: + name: "github-pages" + url: "${{ steps.deployment.outputs.page_url }}" + steps: + - name: "Deploy docs to GitHub Pages" + id: "deployment" + uses: "actions/deploy-pages@v4" diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b6a57d..1b97b4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog], and this project adheres to ## Unreleased ### Added +- Deploy docs to GitHub Pages via GitHub Actions. - Add MkDocs based docs. ## [v2.0.2](https://github.com/pawelad/fakester/releases/tag/v2.0.2) - 2023-04-02 diff --git a/noxfile.py b/noxfile.py index a990e0d..b49ac14 100644 --- a/noxfile.py +++ b/noxfile.py @@ -23,6 +23,19 @@ def tests(session: nox.Session) -> None: session.run("pytest", *dirs) +@nox.session() +def docs(session: nox.Session) -> None: + """Build docs.""" + # fmt: off + session.install( + "--no-deps", + "-r", "requirements/dev.txt", + ) + # fmt: on + + session.run("mkdocs", "build", "--strict") + + @nox.session() def code_style_checks(session: nox.Session) -> None: """Check code style."""