Deploy documentation #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy documentation | |
on: | |
# (A) Wait until the "Build documentation" workflow completes, | |
# but ONLY if the branch is master | |
workflow_run: | |
workflows: ["Build documentation"] # Must match the 'name:' in build-docs.yml | |
branches: [ "master" ] | |
types: [ completed ] | |
# (B) Also trigger if a new release is created or published | |
release: | |
types: [created, published] | |
# (C) Or trigger manually | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
deploy-docs: | |
# Run only if: | |
# - This was triggered by a 'workflow_run' event | |
# (which must have concluded successfully AND was a push event), | |
# OR | |
# - This was triggered by a release event, | |
# OR | |
# - This was triggered by a manual workflow_dispatch. | |
if: > | |
(github.event_name == 'workflow_run' && | |
github.event.workflow_run.conclusion == 'success' && | |
github.event.workflow_run.event == 'push') || | |
github.event_name == 'release' || | |
github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Get run ID of "Build documentation" workflow | |
id: get-run-id | |
run: | | |
REPO_NAME="${{ github.repository }}" | |
WF_NAME="Build documentation" | |
RUN_ID=`gh run --repo ${REPO_NAME} list --workflow "${WF_NAME}" --json databaseId --jq .[0].databaseId` | |
echo "Detected latest run id of ${RUN_ID} for workflow ${WF_NAME}" | |
echo "run-id=${RUN_ID}" >> "$GITHUB_OUTPUT" | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Download artifact from "Test" workflow | |
uses: actions/download-artifact@v4 | |
with: | |
name: docs-artifact # Match name used in build-docs.yml upload artifact step | |
github-token: ${{ github.token }} | |
repository: ${{ github.repository }} | |
run-id: ${{ steps.get-run-id.outputs.run-id }} | |
path: docs_html | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Upload artifact to GH Pages | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: docs_html | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |