|
| 1 | +# Publish |
| 2 | +name: publish workflow |
| 3 | + |
| 4 | +on: |
| 5 | + # Triggers the workflow on push events but only for the master branch |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | + # Allows you to run this workflow manually from the Actions tab |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + pages: write |
| 16 | + id-token: write |
| 17 | + |
| 18 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 19 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 20 | +concurrency: |
| 21 | + group: "pages" |
| 22 | + cancel-in-progress: false |
| 23 | + |
| 24 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 25 | +jobs: |
| 26 | + # Build job |
| 27 | + build: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v3 |
| 32 | + |
| 33 | + - name: setup Python |
| 34 | + uses: actions/setup-python@v4 |
| 35 | + with: |
| 36 | + python-version: "3.10" |
| 37 | + |
| 38 | + - name: Setup Pages |
| 39 | + id: pages |
| 40 | + uses: actions/configure-pages@v3 |
| 41 | + |
| 42 | + - name: Install and configure Poetry |
| 43 | + uses: GNS-Science/install-poetry@main |
| 44 | + with: |
| 45 | + virtualenvs-create: true |
| 46 | + virtualenvs-in-project: true |
| 47 | + installer-parallel: true |
| 48 | + |
| 49 | + #---------------------------------------------- |
| 50 | + # load cached venv if cache exists |
| 51 | + #---------------------------------------------- |
| 52 | + - name: Load cached venv |
| 53 | + id: cached-poetry-dependencies |
| 54 | + uses: actions/cache@v3 |
| 55 | + with: |
| 56 | + path: .venv |
| 57 | + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 58 | + |
| 59 | + #---------------------------------------------- |
| 60 | + # install dependencies if cache does not exist |
| 61 | + #---------------------------------------------- |
| 62 | + - name: Install dependencies |
| 63 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 64 | + run: | |
| 65 | + poetry install --with doc |
| 66 | +
|
| 67 | + - name: Build documentation |
| 68 | + run: | |
| 69 | + poetry run mkdocs build |
| 70 | +
|
| 71 | + - name: Upload artifact |
| 72 | + uses: actions/upload-pages-artifact@v2 |
| 73 | + with: |
| 74 | + path: ./site |
| 75 | + |
| 76 | + # Deployment job |
| 77 | + deploy: |
| 78 | + environment: |
| 79 | + name: github-pages |
| 80 | + url: ${{ steps.deployment.outputs.page_url }} |
| 81 | + runs-on: ubuntu-latest |
| 82 | + needs: build |
| 83 | + steps: |
| 84 | + - name: Deploy to GitHub Pages |
| 85 | + id: deployment |
| 86 | + uses: actions/deploy-pages@v2 |
0 commit comments