Skip to content
Closed
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
40 changes: 22 additions & 18 deletions .github/workflows/_docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
on:
workflow_call:

permissions:
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -28,27 +32,27 @@ jobs:
- name: Remove environment.pickle
run: rm build/html/.doctrees/environment.pickle

- name: Upload built docs artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: docs
path: build

- name: Sanitize ref name for docs version
run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV

- name: Move to versioned directory
run: mv build/html .github/pages/$DOCS_VERSION
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: .github/pages/

- name: Write switcher.json
run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json
- name: Zip main docs
if: github.ref_name == 'main'
run: |
mv build/html main
zip -r docs.zip main

- name: Publish Docs to gh-pages
if: github.ref_type == 'tag' || github.ref_name == 'main'
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
- name: Upload main docs.zip to main pre-release
if: github.ref_name == 'main'
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .github/pages
keep_files: true
tag_name: main-docs
prerelease: true
files: docs.zip
name: "Lastest main branch docs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
30 changes: 30 additions & 0 deletions .github/workflows/_pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Download and unpack docs.zip from every release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -veuo pipefail
mkdir -p site

# Iterate overall every release
for tag in $(gh api --paginate "repos/${{ github.repository }}/releases" --jq '.[].tag_name'); do
echo "::group::$tag"
if gh release download "$tag" -R "${{ github.repository}}" -p docs.zip -D "/tmp/$tag"; then
unzip "/tmp/$tag/docs.zip" -d site
else
echo "No docs.zip on release $tag"
fi
echo "::endgroup::"
done

- name: Generate switcher.json
run: python .github/pages/make_switcher.py site/switcher.json
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
uses: ./.github/workflows/_docs.yml
permissions:
contents: write
pages: write
id-token: write

dist:
uses: ./.github/workflows/_dist.yml
Expand All @@ -61,3 +63,12 @@ jobs:
uses: ./.github/workflows/_release.yml
permissions:
contents: write

pages:
needs: [docs] #might need needs: [releases]
if: github.ref_type == 'tag' || github.ref_type == 'main'
uses: ./.github/workflows/_pages.yml
permissions:
pages: write
id-token: write
contents: read
Loading