Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use official actions to publish the API docs #108

Merged
merged 2 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/actions/publish-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish API docs

outputs:
docs_url:
description: "Deployed URL"
value: ${{ steps.deployment.outputs.page_url }}/docs/

runs:
using: "composite"

steps:

- name: Prepare GitHub Pages
run: |
mkdir website
cat >website/index.html <<!
<DOCTYPE html>
<meta http-equiv="refresh" content="0;URL=./docs/">
<a href="./docs/">Click here if not redirected</a>
!
mv apidocs website/docs
shell: bash

- uses: actions/upload-pages-artifact@v3
with:
path: website

- uses: actions/deploy-pages@v4
id: deployment
22 changes: 6 additions & 16 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ on:

permissions:
contents: read
# Required to publish to Pages:
pages: write
id-token: write


defaults:
Expand Down Expand Up @@ -82,22 +85,9 @@ jobs:
# GitHub Actions VM have 2 CPUs.
tox --parallel 2 --installpkg dist/*.whl

- name: Prepare GitHub Pages
if: contains(matrix['tox-env'], 'apidocs')
run: |
mkdir website
touch website/index.html
mv apidocs website/docs

- name: Publish documentation for push on trunk
# Since we don't have a separate job for apidocs gh-pages updating
# hijack the normal apidoc test and publish the resulting files.
if: contains(matrix['tox-env'], 'apidocs') && github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: Publish docs for ${{ github.sha }}
publish_dir: ./website
- name: Publish API docs
if: contains(matrix['tox-env'], 'apidocs') && github.ref == 'refs/heads/trunk'
uses: ./.github/actions/publish-docs

- name: Prepare coverage results
if: ${{ !cancelled() && !matrix.skip-coverage }}
Expand Down