|
| 1 | +name: Build & Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: [Algorithm Analysis] |
| 6 | + types: |
| 7 | + - completed |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + pages: write |
| 11 | + id-token: write |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + environment: |
| 15 | + name: github-pages |
| 16 | + url: ${{ steps.deployment.outputs.page_url }} |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - name: Setup Pages |
| 21 | + uses: actions/configure-pages@v4 |
| 22 | + - name: Set up Python |
| 23 | + id: setup_python |
| 24 | + uses: actions/setup-python@v5 |
| 25 | + with: |
| 26 | + python-version: "3.11" |
| 27 | + - name: Cache pip |
| 28 | + uses: actions/cache@v3 |
| 29 | + id: pip-cache |
| 30 | + with: |
| 31 | + key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 32 | + path: ${{ env.pythonLocation }} |
| 33 | + if: steps.pip-cache.outputs.cache-hit != 'true' |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: | |
| 37 | + pip install -r requirements.txt |
| 38 | +
|
| 39 | + # Action to download artifacts from a different workflow (analysis.yml) |
| 40 | + - name: 'Download artifact' |
| 41 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 42 | + uses: actions/github-script@v6 |
| 43 | + with: |
| 44 | + script: | |
| 45 | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
| 46 | + owner: context.repo.owner, |
| 47 | + repo: context.repo.repo, |
| 48 | + run_id: context.payload.workflow_run.id, |
| 49 | + }); |
| 50 | + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { |
| 51 | + return artifact.name == "Figures" |
| 52 | + })[0]; |
| 53 | + let download = await github.rest.actions.downloadArtifact({ |
| 54 | + owner: context.repo.owner, |
| 55 | + repo: context.repo.repo, |
| 56 | + artifact_id: matchArtifact.id, |
| 57 | + archive_format: 'zip', |
| 58 | + }); |
| 59 | + let fs = require('fs'); |
| 60 | + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/Figures.zip`, Buffer.from(download.data)); |
| 61 | +
|
| 62 | + - name: 'Unzip artifact' |
| 63 | + run: unzip Figures.zip |
| 64 | + |
| 65 | + - name: Build html |
| 66 | + run: | |
| 67 | + mkdir docs/_static |
| 68 | + mv *.pdf docs/_static/ |
| 69 | + sphinx-apidoc -o docs src |
| 70 | + cd docs/ |
| 71 | + make html |
| 72 | +
|
| 73 | + - name: Upload docs artifact |
| 74 | + uses: actions/upload-pages-artifact@v3 |
| 75 | + with: |
| 76 | + path: 'docs/_build/html' |
| 77 | + |
| 78 | + - name: Deploy to GitHub Pages |
| 79 | + id: deployment |
| 80 | + uses: actions/deploy-pages@v4 |
0 commit comments