| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| name: Build and Deploy Docs |
| |
| on: |
| push: |
| branches: |
| - main |
| pull_request: |
| branches: |
| - main |
| |
| permissions: |
| contents: write |
| |
| concurrency: |
| group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }} |
| cancel-in-progress: true |
| |
| jobs: |
| build-docs: |
| name: Build Documentation |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v7 |
| |
| - uses: actions/setup-python@v6 |
| with: |
| python-version: "3.13" |
| |
| - name: Install docs requirements |
| run: pip install -r docs/requirements.txt |
| |
| - name: Build documentation |
| # Using mkdocs build is the standard way to generate the site |
| run: mkdocs build |
| |
| - name: Compress docs for artifact upload |
| run: | |
| # The update-asf-site job expects a specific folder name inside the tarball |
| cp -R site documentation-site |
| tar -czf docs.tgz documentation-site |
| |
| - name: Upload docs artifact |
| uses: actions/upload-artifact@v7 |
| with: |
| name: docs |
| retention-days: 2 |
| path: docs.tgz |
| |
| update-asf-site: |
| name: Deploy Dev Snapshot |
| runs-on: ubuntu-latest |
| needs: |
| - build-docs |
| # This job should only run on pushes to the main branch |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| |
| steps: |
| - uses: actions/download-artifact@v8 |
| with: |
| name: docs |
| |
| - name: Clone asf-site branch |
| uses: actions/checkout@v7 |
| with: |
| ref: asf-site |
| path: pages-clone |
| |
| - name: Update development documentation |
| run: | |
| git config --global user.email "actions@github.com" |
| git config --global user.name "GitHub Actions" |
| |
| cd pages-clone |
| # Remove all existing content except .git directory |
| find . -maxdepth 1 -not -name '.git' -not -name '.' -exec rm -rf {} + |
| |
| tar -xf ../docs.tgz |
| # Move all content from documentation-site to root of asf-site branch |
| mv documentation-site/* . |
| mv documentation-site/.* . 2>/dev/null || true |
| rmdir documentation-site |
| |
| git add * |
| git commit --allow-empty -m"update documentation for main branch" |
| |
| - name: Push development documentation to asf-site |
| # Ensure this push only happens on the intended repository |
| if: success() && github.repository == 'apache/sedona-spatialbench' |
| run: | |
| cd pages-clone |
| git push |