Skip to content

Add second edition of the book (#1096) #1967

Add second edition of the book (#1096)

Add second edition of the book (#1096) #1967

Workflow file for this run

# 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']
pull_request:
jobs:
build:
runs-on: ["ubuntu-22.04"]
steps:
# 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
submodules: recursive
lfs: true
fetch-depth: 1
- 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: Display disk free
run: /mnt/airflow-site/.github/scripts/print_df.sh
working-directory: /mnt/airflow-site
- name: 🐍 Setup Python
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1
with:
python-version: '3.7'
- name: ❀️ Install Node 16
uses: actions/[email protected] # v3.3.0
with:
node-version: 16
- name: πŸ“š Install Hugo
uses: peaceiris/[email protected] # v2.4.13
with:
hugo-version: '0.91.2'
extended: true
- name: 🟒 Install node dependencies
run: |
/mnt/airflow-site/site.sh install-node-deps
/mnt/airflow-site/.github/scripts/print_df.sh
- name: 🐍 Install Python dependencies
run: |
pip install -r requirements.txt
/mnt/airflow-site/.github/scripts/print_df.sh
- name: Ensure cache directory exists and adjust permissions
run: |
mkdir -p /mnt/airflow-site/.cache/pre-commit
sudo chmod -R 777 /mnt/airflow-site/.cache/pre-commit
- name: πŸ”Ž Lint
uses: apache/airflow-pre-commit-action@0764670bf370aab253130d534e1eda7ff497dc60 # v2.0.0
env:
PRE_COMMIT_HOME: /mnt/airflow-site/.cache/pre-commit
- name: πŸ—‚ Checkout gh-pages branch with minimum depth
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # 3.5.3
if: ${{ github.event_name == 'push' }}
with:
ref: gh-pages
fetch-depth: 1
path: dist
- name: πŸ”§ Build site
run: |
/mnt/airflow-site/site.sh build-site
/mnt/airflow-site/.github/scripts/print_df.sh
- run: |
rm -rf ./docs-archive/*
echo "docs-archive directory files are deleted as they are no longer needed after the site is built in the above step"
/mnt/airflow-site/.github/scripts/print_df.sh
- name: πŸ… Optimize artifacts
if: ${{ github.event_name == 'pull_request' }}
run: |
rm -rf ./dist/docs/*
echo "These files have been deleted to optimize the size of the artifacts." > ./dist/docs/index.html
echo "Here was the contents of the ./docs-archive directory" >> ./dist/docs/index.html
find ./dist/
/mnt/airflow-site/.github/scripts/print_df.sh
- uses: actions/upload-artifact@v4
name: πŸš€ Upload website as artifact
if: ${{ github.event_name == 'pull_request' }}
with:
name: airflow-website
path: './dist'
if-no-files-found: error
retention-days: 14
- name: πŸ‘· Copy .asf.yaml to /dist/
if: ${{ github.event_name == 'push' }}
run: |
# The asf.yaml file must be in the branch from which the files are published.
# Otherwise, ASF publising tools cannot detect it.
cp .asf.yaml ./dist/
/mnt/airflow-site/.github/scripts/print_df.sh
- name: πŸͺ“ Remove node and node modules
run: |
rm -rf node_modules
sudo rm -rf "$AGENT_TOOLSDIRECTORY/node"
/mnt/airflow-site/.github/scripts/print_df.sh
- name: πŸš€ Amend gh-pages branch and deploy it with force (replacing previous pages)
if: ${{ github.event_name == 'push' }}
working-directory: dist
run: |
../.github/scripts/print_df.sh
echo "Running git config"
git config user.name "GitHub Actions"
git config user.email "[email protected]"
echo "Running git add"
git add .
../.github/scripts/print_df.sh
echo "Running git commit"
git commit --amend --no-edit > ../git_commit.log
../.github/scripts/print_df.sh
git push --force origin gh-pages
../.github/scripts/print_df.sh
- name: πŸš€ Upload git commit log as artifacts
uses: actions/upload-artifact@v4
with:
name: airflow-git-commit-log
path: './git_commit.log'
retention-days: 5
- name: πŸ”§ Copy files from site to theme
run: |
./site.sh prepare-theme
./.github/scripts/print_df.sh
- name: πŸ”§ Prepare sphinx_airflow_theme package ️
working-directory: sphinx_airflow_theme
run: |
python3 -m pip install --user --upgrade setuptools wheel
python3 setup.py sdist bdist_wheel
../.github/scripts/print_df.sh
- name: πŸš€ Upload sphinx_airflow_theme package as artifact
uses: actions/upload-artifact@v4
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
../../.github/scripts/print_df.sh
- name: πŸš€ Upload sphinx_airflow_theme demo as artifact
uses: actions/upload-artifact@v4
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: >
github.ref == 'refs/heads/main' && github.repository == 'apache/airflow-site' &&
github.event_name == 'push'
run: |
set -x
gh auth status
VERSION="$(python setup.py --version 2>/dev/null | tail -1)"
TITLE=$(date "+%Y-%m-%d %H:%M:%S")
NOTES="Commit: ${GITHUB_COMMIT}
Source: ${GITHUB_REF}"
gh release delete "${VERSION}" -y || true
gh release create "${VERSION}" \
--title "${TITLE}" \
--notes "${NOTES}" \
./dist/*
../.github/scripts/print_df.sh