rattler/.github/workflows/docs.yaml

183 lines
6.1 KiB
YAML

name: Deploy Docs
on:
push:
branches:
- main
paths:
- "py-rattler/docs/**"
- "py-rattler/mkdocs.yml"
- "py-rattler/pixi.toml"
- "py-rattler/rattler/**"
- "crates/**"
- "Cargo.toml"
- ".github/workflows/docs.yaml"
pull_request:
branches:
- main
paths:
- "py-rattler/docs/**"
- "py-rattler/mkdocs.yml"
- "py-rattler/pixi.toml"
- "py-rattler/rattler/**"
- ".github/workflows/docs.yaml"
workflow_dispatch:
inputs:
tag:
description: "Tag to deploy py-rattler docs (e.g. py-rattler-v0.23.0), or leave empty for dev"
required: false
default: ""
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: --html-in-header header.html
permissions:
contents: read
jobs:
# ── PR check: just build, don't deploy ──
build-docs:
if: github.repository == 'conda/rattler' && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: recursive
- uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
with:
manifest-path: py-rattler/pixi.toml
environments: docs
- name: Build Py-rattler Documentation
run: pixi run --manifest-path py-rattler/pixi.toml build-docs
# ── Rust docs: deploy cargo doc to gh-pages on every push to main ──
rust-docs:
if: >-
github.repository == 'conda/rattler' &&
github.event_name == 'push' &&
github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: gh-pages-deploy
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: recursive
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
- name: Pre-docs-build
run: |
echo "<meta name=\"robots\" content=\"noindex\">" > header.html
- name: Build Rattler Documentation
run: cargo doc --workspace --no-deps --all-features --lib
- name: Deploy rustdoc to gh-pages
run: |
git clone --branch gh-pages https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git gh-pages-repo
cp -r target/doc/. gh-pages-repo/
echo '<meta http-equiv="refresh" content="0; url=rattler/index.html">' > gh-pages-repo/index.html
echo "User-Agent: *" > gh-pages-repo/robots.txt
echo "Disallow: /" >> gh-pages-repo/robots.txt
touch gh-pages-repo/.nojekyll
cd gh-pages-repo
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add .
git diff --staged --quiet || (git commit -m "docs: update rustdoc" && git push)
# ── py-rattler docs (dev): deploy to "dev" alias on every push to main ──
py-rattler-docs-dev:
if: >-
github.repository == 'conda/rattler' &&
((github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.tag == ''))
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: gh-pages-deploy
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: recursive
- uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
with:
manifest-path: py-rattler/pixi.toml
environments: docs
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Deploy with mike
run: pixi run --manifest-path py-rattler/pixi.toml deploy-dev
# ── py-rattler docs (release): deploy to "latest" alias via manual trigger ──
py-rattler-docs-release:
if: >-
github.repository == 'conda/rattler' &&
github.event_name == 'workflow_dispatch' &&
github.event.inputs.tag != ''
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: gh-pages-deploy
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: recursive
- name: Checkout tag
env:
INPUT_TAG: ${{ github.event.inputs.tag }}
run: git checkout "tags/$INPUT_TAG"
- uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
with:
manifest-path: py-rattler/pixi.toml
environments: docs
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Set version
env:
INPUT_TAG: ${{ github.event.inputs.tag }}
run: echo "RELEASE_VERSION=${INPUT_TAG#py-rattler-}" >> $GITHUB_ENV
- name: Deploy with mike
run: pixi run --manifest-path py-rattler/pixi.toml deploy-latest
- name: Add py-rattler redirect to latest
run: |
git clone --branch gh-pages https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git gh-pages-repo
echo '<meta http-equiv="refresh" content="0; url=latest/">' > gh-pages-repo/py-rattler/index.html
cd gh-pages-repo
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add .
git diff --staged --quiet || (git commit -m "docs: update py-rattler redirect" && git push)