Skip to content

ci: separate deploy step for MkDocs docs on push to main #116

ci: separate deploy step for MkDocs docs on push to main

ci: separate deploy step for MkDocs docs on push to main #116

name: Python package
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: write # Necessario per il deploy su gh-pages
issues: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
pip install poetry==1.8.4
poetry install
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
poetry run pytest
- name: Build docs with MkDocs
run: |
poetry run mkdocs build --strict
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install MkDocs and dependencies
run: |
pip install poetry mkdocs
poetry install
- name: Configure Git
run: |
git config --global user.name "MkDocs CI"
git config --global user.email "ci@mkdocs.deploy"
- name: Deploy docs to gh-pages
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry run mkdocs gh-deploy --force