| # 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 docs |
| |
| on: |
| push: |
| branches: ['main', 'staging'] |
| pull_request: |
| workflow_dispatch: |
| permissions: |
| contents: write |
| concurrency: |
| group: build-${{ github.ref }} |
| cancel-in-progress: true |
| jobs: |
| build: |
| runs-on: ["ubuntu-22.04"] |
| env: |
| PROD_PUBLISH_REQUIRED: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' || 'false' }} |
| STAGING_PUBLISH_REQUIRED: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/staging' || 'false' }} |
| PUBLISH_BRANCH: ${{ github.ref == 'refs/heads/main' && 'publish' || 'staging-publish' }} |
| CLOUDFRONT_DISTRIBUTION_ID: ${{ github.ref == 'refs/heads/main' && 'E26P75MP9PMULE' || 'E197MS0XRJC5F3' }} |
| S3_DOCS_BUCKET: ${{ github.ref == 'refs/heads/main' && 'live-docs-airflow-apache-org' || 'staging-docs-airflow-apache-org' }} |
| steps: |
| - name: βΉοΈ Info |
| run: | |
| echo "PROD_PUBLISH_REQUIRED: ${PROD_PUBLISH_REQUIRED}" |
| echo "STAGING_PUBLISH_REQUIRED: ${STAGING_PUBLISH_REQUIRED}" |
| # Based on https://github.com/actions/runner-images/issues/2840 |
| - name: πͺ Remove some stuff we don't need |
| run: | |
| sudo rm -rf /usr/share/dotnet |
| sudo rm -rf /opt/ghc |
| sudo rm -rf "/usr/local/share/boost" |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" |
| - name: π’ Install stuff we need |
| run: | |
| type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) |
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ |
| && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ |
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ |
| && sudo apt update \ |
| && sudo apt install gh -y |
| - name: π Checkout |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| submodules: recursive |
| fetch-depth: 1 |
| persist-credentials: false |
| - name: πCreate /mnt/airflow-site directory |
| run: sudo mkdir -p /mnt/airflow-site |
| - name: πMove repository to /mnt |
| run: | |
| sudo mv /home/runner/work/airflow-site/airflow-site /mnt/ |
| # Create symbolic link |
| sudo mkdir -p /home/runner/work/airflow-site |
| sudo ln -s /mnt/airflow-site /home/runner/work/airflow-site/airflow-site |
| - name: πSet working directory to /mnt/airflow-site |
| working-directory: /mnt/airflow-site |
| run: echo "Working directory set to /mnt/airflow-site" |
| - name: π Setup Python |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| with: |
| python-version: '3.12' |
| - name: β€οΈ Install Node 22 LTS |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 |
| with: |
| node-version: 22 |
| - name: π Install Hugo |
| run: | |
| HUGO_VERSION="0.157.0" |
| curl -fsSL "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" | sudo tar -xz -C /usr/local/bin hugo |
| - name: π¦ Install Docsy theme dependencies (Bootstrap & FontAwesome) |
| working-directory: /mnt/airflow-site/landing-pages/site/themes/docsy |
| run: npm install |
| - name: π’ Install node dependencies |
| run: | |
| /mnt/airflow-site/site.sh install-node-deps |
| - name: π Install uv |
| run: | |
| curl -LsSf https://astral.sh/uv/install.sh | sh |
| - name: Ensure cache directory exists and adjust permissions |
| run: | |
| mkdir -p /mnt/airflow-site/.cache/prek |
| sudo chmod -R 777 /mnt/airflow-site/.cache/prek |
| - name: π Lint |
| run: | |
| uv tool install prek |
| prek run --all-files --color always |
| - name: π Checkout ${{ env.PUBLISH_BRANCH }} branch with minimum depth |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| ref: ${{ env.PUBLISH_BRANCH }} |
| fetch-depth: 1 |
| path: dist |
| set-safe-directory: 'true' |
| # We will push to the publish branch |
| persist-credentials: true |
| - name: π§ Build site |
| run: | |
| /mnt/airflow-site/site.sh build-site |
| - name: β nstall AWS CLI v2 |
| if: env.PROD_PUBLISH_REQUIRED != 'false' || env.STAGING_PUBLISH_REQUIRED != 'false' |
| run: | |
| curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o /tmp/awscliv2.zip |
| unzip -q /tmp/awscliv2.zip -d /tmp |
| rm /tmp/awscliv2.zip |
| sudo /tmp/aws/install --update |
| rm -rf /tmp/aws/ |
| - name: β Configure AWS credentials |
| if: env.PROD_PUBLISH_REQUIRED != 'false' || env.STAGING_PUBLISH_REQUIRED != 'false' |
| uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0 |
| with: |
| aws-access-key-id: ${{ secrets.DOCS_AWS_ACCESS_KEY_ID }} |
| aws-secret-access-key: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY }} |
| aws-region: us-east-2 |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| name: π Upload website as artifact |
| if: ${{ github.event_name == 'pull_request' }} |
| with: |
| name: airflow-website |
| path: './dist' |
| if-no-files-found: error |
| retention-days: 7 |
| - name: "π§ͺ Apply staging modifications: .htaccess and watermarks" |
| run: | |
| set -x |
| sed -i 's/d7fnmbhf26p21.cloudfront.net/d3a2du7x0n8ydr.cloudfront.net/' ./dist/.htaccess |
| echo "Updated ./dist/.htaccess" |
| cat ./dist/.htaccess |
| echo |
| uv run .github/scripts/add_watermark.py --pattern 'main*.css' \ |
| --folder dist --image-directory images --url-prefix /images |
| if: github.ref == 'refs/heads/staging' |
| - name: π· Copy .asf.yaml to /dist/ |
| if: env.PROD_PUBLISH_REQUIRED != 'false' || env.STAGING_PUBLISH_REQUIRED != 'false' |
| run: | |
| # The asf.yaml file must be in the branch from which the files are published. |
| # Otherwise, ASF publishing tools cannot detect it. |
| cp .asf.yaml ./dist/ |
| - name: πͺ Remove node and node modules |
| run: | |
| rm -rf node_modules |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY/node" |
| - name: π§ Copy files from site to theme |
| run: | |
| ./site.sh prepare-theme |
| - name: π§ Prepare sphinx_airflow_theme package οΈ |
| working-directory: sphinx_airflow_theme |
| run: | |
| uv build |
| - name: π¦ Copy sphinx_airflow_theme package to dist |
| run: | |
| mkdir -p dist/sphinx-airflow-theme |
| cp sphinx_airflow_theme/dist/* dist/sphinx-airflow-theme/ |
| - name: πRefresh PMC/COMMITTERS profiles |
| env: |
| PMC_COMMITTERS_FILES: landing-pages/site/data/committers.json,landing-pages/site/data/pmc.json |
| run: | |
| uv run ./.github/scripts/refresh_pmc_committer_images.py |
| - name: π Add commit to ${{ env.PUBLISH_BRANCH }} branch and deploy it |
| if: env.PROD_PUBLISH_REQUIRED != 'false' || env.STAGING_PUBLISH_REQUIRED != 'false' |
| working-directory: dist |
| run: | |
| set -x |
| echo "Running git config" |
| git config user.name "GitHub Actions" |
| git config user.email "actions@users.noreply.github.com" |
| echo "Running git add" |
| git add . |
| git diff HEAD |
| echo "Running git commit" |
| git commit --no-edit -m "Docs updated via ${GITHUB_REF}:${{ github.sha }}" --allow-empty |
| echo "Running git push to ${PUBLISH_BRANCH} branch" |
| git push origin ${PUBLISH_BRANCH} |
| - name: π Upload sphinx_airflow_theme package as artifact |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| with: |
| name: airflow-sphinx-theme |
| path: './sphinx_airflow_theme/dist' |
| if-no-files-found: error |
| retention-days: 14 |
| - name: π§ Build theme demo |
| working-directory: sphinx_airflow_theme |
| run: | |
| pip install ./dist/sphinx_airflow_theme-*.whl |
| cd demo |
| ./docs.sh build |
| - name: π Upload sphinx_airflow_theme demo as artifact |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| with: |
| name: airflow-sphinx-theme-demo |
| path: './sphinx_airflow_theme/demo/_build' |
| if-no-files-found: error |
| retention-days: 14 |
| - name: π Create releases on GitHub |
| working-directory: sphinx_airflow_theme |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| GITHUB_COMMIT: ${{ github.sha }} |
| GITHUB_REF: ${{ github.ref }} |
| if: env.PROD_PUBLISH_REQUIRED != 'false' || env.STAGING_PUBLISH_REQUIRED != 'false' |
| run: | |
| set -x |
| if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then |
| SUFFIX="" |
| else |
| SUFFIX="-staging" |
| fi |
| gh auth status |
| VERSION="$(cd sphinx_airflow_theme; uv run python -c 'import sphinx_airflow_theme; print(sphinx_airflow_theme.__version__)')" |
| TITLE=$(date "+%Y-%m-%d %H:%M:%S") |
| NOTES="Commit: ${GITHUB_COMMIT} |
| Source: ${GITHUB_REF}" |
| |
| gh release delete "${VERSION}${SUFFIX}" -y || true |
| gh release create "${VERSION}${SUFFIX}" \ |
| --title "${TITLE}" \ |
| --notes "${NOTES}" \ |
| ./dist/* |