Skip to content

Deploy Docs Consumer (Runs manually or on cron) #20013

Deploy Docs Consumer (Runs manually or on cron)

Deploy Docs Consumer (Runs manually or on cron) #20013

Workflow file for this run

name: Deploy Docs Consumer (Runs manually or on cron)
on:
schedule:
- cron: '*/15 * * * *' # every 15 minutes
workflow_dispatch: # manual trigger via GitHub UI
permissions:
contents: write
pages: write
id-token: write
jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- name: Configure git identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Checkout workflow-queue branch
uses: actions/checkout@v4
with:
ref: workflow-queue
fetch-depth: 0
- name: Configure authenticated GitHub URL for future clones
run: |
echo "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com" > ~/.git-credentials
git config --global credential.helper store
- name: Grab queue, clear, and process all branches
run: |
set -euo pipefail
touch queue.txt
QUEUE_LENGTH=$(grep -c -v '^\s*$' queue.txt || true)
if [[ "$QUEUE_LENGTH" == "0" ]]; then
echo "Queue is empty. Nothing to process."
exit 0
fi
mapfile -t QUEUE < queue.txt
for i in "${!QUEUE[@]}"; do
QUEUE[$i]=$(echo "${QUEUE[$i]}" | tr -d '[:space:]')
done
CLEAN_QUEUE=()
for item in "${QUEUE[@]}"; do
if [[ -n "$item" ]]; then
CLEAN_QUEUE+=("$item")
fi
done
QUEUE=("${CLEAN_QUEUE[@]}")
> queue.txt
git add queue.txt
git commit -m "Cleared queue for processing"
git push origin workflow-queue
TMPDIR=$(mktemp -d)
echo "Working in $TMPDIR"
git clone https://github.com/${{ github.repository }} "$TMPDIR"
cd "$TMPDIR"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
for BRANCH in "${QUEUE[@]}"; do
if ! echo "$BRANCH" | grep -Eq '^main$|^release-v[0-9]+(\.[0-9]+)*$'; then
echo "Skipping invalid branch: $BRANCH"
continue
fi
echo "=== Processing $BRANCH ==="
if ! git checkout "$BRANCH"; then
echo "ERROR: Branch $BRANCH doesn't exist, skipping"
continue
fi
rm -rf .venv
python3 -m venv .venv
source .venv/bin/activate
if [ -f requirements.txt ]; then
echo "Installing requirements for $BRANCH"
pip install -r requirements.txt
else
echo "No requirements.txt in $BRANCH — skipping pip install"
fi
echo "Deploying docs for branch: $BRANCH"
git fetch origin gh-pages || echo "gh-pages does not exist remotely"
if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
git branch -f gh-pages origin/gh-pages
else
echo "No origin/gh-pages ref — skipping branch sync"
fi
if [[ "$BRANCH" == "main" ]]; then
mike deploy -t "next" --update-aliases --push --alias-type=copy next head
elif [[ "$BRANCH" == "release-v1.7.0" ]]; then
mike deploy -t "v1.7.0 (latest)" --update-aliases --push --alias-type=copy v1.7.0 latest stable
mike set-default --push latest
else
version="${BRANCH#release-}"
mike deploy -t "$version" --update-aliases --push "$version"
fi
deactivate
done
echo "All branches processed."