Skip to content

Commit

Permalink
Merge pull request #108 from twisted/98-apidocs
Browse files Browse the repository at this point in the history
Use official actions to publish the API docs
  • Loading branch information
twm authored Aug 11, 2024
2 parents 6219fbf + d48d044 commit 27764c3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
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

0 comments on commit 27764c3

Please sign in to comment.