name: Preview on: workflow_dispatch: pull_request: types: [opened, synchronize, reopened, ready_for_review] # Run the workflow only when one of these files changes. src/axolotl is # included because quartodoc renders API docs from the whole package — # removing a module it tracks breaks the build (see _quarto.yml sections) paths: - '**/*.md' # any Markdown file - '**/*.qmd' # any Quarto file - '_quarto.yml' - 'docs/**' - 'src/axolotl/**.py' - .github/workflows/preview-docs.yml concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} permissions: contents: read pull-requests: write jobs: preview: runs-on: ubuntu-latest if: ${{ !github.event.pull_request.draft }} steps: - name: cleanup node run: | sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL - name: Check out repository uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha }} - name: Set up Quarto uses: quarto-dev/quarto-actions/setup@8a96df13519ee81fd526f2dfca5962811136661b # v2.2.0 - name: Setup Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: '3.11' - name: Install dependencies run: | python3 -m pip install jupyter quartodoc python3 -m pip install -e . - name: Build autodoc run: quartodoc build - name: Quarto render run: quarto render # everything above runs credential-free on every PR (including forks) so # a broken docs build fails CI; publishing needs the Netlify secrets, # which only same-repo branches get - name: Netlify Publish uses: nwtgck/actions-netlify@d22a32a27c918fe470bbc562e984f80ec48c2668 # v4.0.0 if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} id: netlify with: publish-dir: './_site' enable-pull-request-comment: false enable-github-deployment: false github-token: ${{ secrets.GITHUB_TOKEN }} deploy-message: "Deployed On Netlify" github-deployment-environment: 'preview' github-deployment-description: 'Preview Deployment' env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - name: Update PR with preview link if: ${{ steps.netlify.outcome == 'success' }} uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} message: | 📖 **Documentation Preview**: ${{ steps.netlify.outputs.deploy-url }} Deployed on Netlify from commit ${{ github.event.pull_request.head.sha }}