|
| 1 | +name: Publish GitHub Pages |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | + # Allows you to run this workflow manually from the Actions tab |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + pages: write |
| 19 | + id-token: write |
| 20 | + |
| 21 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 22 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 23 | +concurrency: |
| 24 | + group: "pages" |
| 25 | + cancel-in-progress: false |
| 26 | + |
| 27 | +jobs: |
| 28 | + build: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout code |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: "3.12" |
| 39 | + |
| 40 | + - name: Install dependencies |
| 41 | + run: | |
| 42 | + python -m pip install --upgrade pip |
| 43 | + pip install -r doc/requirements.txt |
| 44 | +
|
| 45 | + - name: get git info |
| 46 | + id: getgitinfo |
| 47 | + run: | |
| 48 | + echo "GITHUB_COMMIT_DATE=$(git --no-pager log -1 --pretty='format:%cd' --date='format:%Y-%m-%d %H:%M:%S')" >> "$GITHUB_OUTPUT" |
| 49 | +
|
| 50 | + - name: Setup Pages |
| 51 | + id: pages |
| 52 | + uses: actions/configure-pages@v5 |
| 53 | + |
| 54 | + - name: build Documentation |
| 55 | + env: |
| 56 | + GH_ACTIONS_GIT_BRANCH: ${{ github.head_ref || github.ref_name }} |
| 57 | + GH_ACTIONS_GIT_COMMIT_DATE: ${{ steps.getgitinfo.outputs.GITHUB_COMMIT_DATE }} |
| 58 | + GH_ACTIONS_GIT_COMMIT_HASH: ${{ github.sha }} |
| 59 | + |
| 60 | + run: | |
| 61 | + sphinx-build -W --keep-going -b html doc/source/ ./_site |
| 62 | +
|
| 63 | + - name: Upload artifact |
| 64 | + # Automatically uploads an artifact from the './_site' directory by default |
| 65 | + uses: actions/upload-pages-artifact@v3 |
| 66 | + |
| 67 | + # Deployment job |
| 68 | + deploy: |
| 69 | + environment: |
| 70 | + name: github-pages |
| 71 | + url: ${{ steps.deployment.outputs.page_url }} |
| 72 | + runs-on: ubuntu-latest |
| 73 | + needs: build |
| 74 | + steps: |
| 75 | + - name: Deploy to GitHub Pages |
| 76 | + id: deployment |
| 77 | + uses: actions/deploy-pages@v4 |
0 commit comments