Skip to content

Commit aee3d3f

Browse files
ci: publish devnotes independently of releases (#536)
* ci: add workflow to publish devnotes independently of releases Adds a GitHub Actions workflow that rebuilds the `latest` docs alias when devnotes change on main, so blog posts go live without cutting a package release. * ci: pin actions to commit SHAs and restrict default permissions Address Greptile review findings: - Pin checkout, setup-uv, and download-artifact to commit SHAs matching the pattern from #517 - Add top-level permissions: {} to restrict default token scope * ci: build devnotes from last deployed state, not main Instead of building the full site from main (which could include unreleased docs), checkout the commit that latest was last built from (tracked in gh-pages commit messages) and overlay only docs/devnotes/ from main. Download notebooks from the last successful build-docs run instead of rebuilding them. * ci: add actions:read permission for notebook download The gh run list/download calls need actions:read on GITHUB_TOKEN, which is denied by the top-level permissions: {} block.
1 parent 47be28c commit aee3d3f

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Publish devnotes
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "docs/devnotes/**"
8+
workflow_dispatch:
9+
10+
permissions: {}
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: write
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
21+
with:
22+
fetch-depth: 0
23+
- name: Get last deployed docs state
24+
run: |
25+
git fetch origin gh-pages --depth=1
26+
DEPLOY_MSG=$(git log FETCH_HEAD -1 --format="%s")
27+
SOURCE_SHA=$(echo "$DEPLOY_MSG" | sed -n 's/^Deployed \([0-9a-f]*\) to .*/\1/p')
28+
VERSION=$(echo "$DEPLOY_MSG" | sed -n 's/^Deployed [0-9a-f]* to \([^ ]*\) .*/\1/p')
29+
30+
if [ -z "$SOURCE_SHA" ] || [ -z "$VERSION" ]; then
31+
echo "::error::Could not parse deploy info from gh-pages. Expected: 'Deployed <sha> to <version> ...'"
32+
exit 1
33+
fi
34+
35+
echo "::notice::Last deploy: commit $SOURCE_SHA for version $VERSION"
36+
echo "SOURCE_SHA=$SOURCE_SHA" >> $GITHUB_ENV
37+
echo "VERSION=$VERSION" >> $GITHUB_ENV
38+
- name: Checkout docs source and overlay devnotes
39+
run: |
40+
git checkout ${{ env.SOURCE_SHA }}
41+
git checkout ${{ github.sha }} -- docs/devnotes/
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
44+
with:
45+
version: "0.9.5"
46+
- name: Set up Python
47+
run: uv python install 3.11
48+
- name: Install dependencies for docs
49+
run: uv sync --all-packages --group docs
50+
- name: Download notebooks from last docs build
51+
env:
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: |
54+
mkdir -p docs/notebooks
55+
LAST_RUN_ID=$(gh run list --workflow build-docs.yml --status success --limit 1 --json databaseId -q '.[0].databaseId')
56+
if [ -z "$LAST_RUN_ID" ]; then
57+
echo "::error::No successful build-docs run found. Cannot build without notebooks."
58+
exit 1
59+
fi
60+
gh run download "$LAST_RUN_ID" --name notebooks --dir docs/notebooks
61+
echo "::notice::Downloaded notebooks from build-docs run $LAST_RUN_ID"
62+
- name: Setup doc deploy
63+
run: |
64+
git config --global user.name "github-actions[bot]"
65+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
66+
- name: Rebuild latest docs
67+
run: uv run mike deploy --push --update-aliases ${{ env.VERSION }} latest

0 commit comments

Comments
 (0)