diff --git a/.github/workflows/publish-devnotes.yml b/.github/workflows/publish-devnotes.yml new file mode 100644 index 00000000..474a2bf5 --- /dev/null +++ b/.github/workflows/publish-devnotes.yml @@ -0,0 +1,67 @@ +name: Publish devnotes + +on: + push: + branches: [main] + paths: + - "docs/devnotes/**" + workflow_dispatch: + +permissions: {} + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + actions: read + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + fetch-depth: 0 + - name: Get last deployed docs state + run: | + git fetch origin gh-pages --depth=1 + DEPLOY_MSG=$(git log FETCH_HEAD -1 --format="%s") + SOURCE_SHA=$(echo "$DEPLOY_MSG" | sed -n 's/^Deployed \([0-9a-f]*\) to .*/\1/p') + VERSION=$(echo "$DEPLOY_MSG" | sed -n 's/^Deployed [0-9a-f]* to \([^ ]*\) .*/\1/p') + + if [ -z "$SOURCE_SHA" ] || [ -z "$VERSION" ]; then + echo "::error::Could not parse deploy info from gh-pages. Expected: 'Deployed to ...'" + exit 1 + fi + + echo "::notice::Last deploy: commit $SOURCE_SHA for version $VERSION" + echo "SOURCE_SHA=$SOURCE_SHA" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Checkout docs source and overlay devnotes + run: | + git checkout ${{ env.SOURCE_SHA }} + git checkout ${{ github.sha }} -- docs/devnotes/ + - name: Install uv + uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7 + with: + version: "0.9.5" + - name: Set up Python + run: uv python install 3.11 + - name: Install dependencies for docs + run: uv sync --all-packages --group docs + - name: Download notebooks from last docs build + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mkdir -p docs/notebooks + LAST_RUN_ID=$(gh run list --workflow build-docs.yml --status success --limit 1 --json databaseId -q '.[0].databaseId') + if [ -z "$LAST_RUN_ID" ]; then + echo "::error::No successful build-docs run found. Cannot build without notebooks." + exit 1 + fi + gh run download "$LAST_RUN_ID" --name notebooks --dir docs/notebooks + echo "::notice::Downloaded notebooks from build-docs run $LAST_RUN_ID" + - name: Setup doc deploy + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Rebuild latest docs + run: uv run mike deploy --push --update-aliases ${{ env.VERSION }} latest