| on: |
| push: |
| branches: |
| - main |
| tags-ignore: |
| - "**-rc**" |
| pull_request: |
| branches: |
| - main |
| |
| name: Deploy DataFusion Python site |
| |
| jobs: |
| debug-github-context: |
| name: Print github context |
| runs-on: ubuntu-latest |
| steps: |
| - name: Dump GitHub context |
| env: |
| GITHUB_CONTEXT: ${{ toJson(github) }} |
| run: | |
| echo "$GITHUB_CONTEXT" |
| build-docs: |
| name: Build docs |
| runs-on: ubuntu-latest |
| steps: |
| - name: Set target branch |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') |
| id: target-branch |
| run: | |
| set -x |
| if test '${{ github.ref }}' = 'refs/heads/main'; then |
| echo "value=asf-staging" >> "$GITHUB_OUTPUT" |
| elif test '${{ github.ref_type }}' = 'tag'; then |
| echo "value=asf-site" >> "$GITHUB_OUTPUT" |
| else |
| echo "Unsupported input: ${{ github.ref }} / ${{ github.ref_type }}" |
| exit 1 |
| fi |
| - name: Checkout docs sources |
| uses: actions/checkout@v5 |
| - name: Checkout docs target branch |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') |
| uses: actions/checkout@v5 |
| with: |
| fetch-depth: 0 |
| ref: ${{ steps.target-branch.outputs.value }} |
| path: docs-target |
| - name: Setup Python |
| uses: actions/setup-python@v5 |
| with: |
| python-version: "3.11" |
| |
| - name: Install Protoc |
| uses: arduino/setup-protoc@v3 |
| with: |
| version: '27.4' |
| repo-token: ${{ secrets.GITHUB_TOKEN }} |
| |
| - name: Install dependencies and build |
| uses: astral-sh/setup-uv@v6 |
| with: |
| enable-cache: true |
| |
| - name: Build repo |
| run: | |
| uv venv |
| uv sync --dev --no-install-package datafusion --group docs |
| uv run --no-project maturin develop --uv |
| |
| - name: Build docs |
| run: | |
| set -x |
| cd docs |
| curl -O https://gist.githubusercontent.com/ritchie46/cac6b337ea52281aa23c049250a4ff03/raw/89a957ff3919d90e6ef2d34235e6bf22304f3366/pokemon.csv |
| curl -O https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-01.parquet |
| uv run --no-project make html |
| |
| - name: Copy & push the generated HTML |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') |
| run: | |
| set -x |
| cd docs-target |
| # delete anything but: 1) '.'; 2) '..'; 3) .git/ |
| find ./ | grep -vE "^./$|^../$|^./.git" | xargs rm -rf |
| cp ../.asf.yaml . |
| cp -r ../docs/build/html/* . |
| git status --porcelain |
| if [ "$(git status --porcelain)" != "" ]; then |
| git config user.name "github-actions[bot]" |
| git config user.email "github-actions[bot]@users.noreply.github.com" |
| git add --all |
| git commit -m 'Publish built docs triggered by ${{ github.sha }}' |
| git push || git push --force |
| fi |