Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/build_javadoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
################################################################################
# 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 Javadocs

on:
workflow_dispatch:
# discuss with Jark
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this TODO comment or replace it with proper documentation explaining the workflow trigger conditions.

Suggested change
# discuss with Jark
# This workflow is triggered manually via the GitHub Actions UI.

Copilot uses AI. Check for mistakes.

jobs:
build-javadocs:
runs-on: ubuntu-latest
steps:
- name: Checkout fluss repository
uses: actions/checkout@v4
with:
repository: apache/fluss
fetch-depth: 0

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'

- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}

- name: Configure git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions Bot"
- name: Checkout fluss-website repository
uses: actions/checkout@v4
with:
repository: apache/fluss-website
token: ${{ secrets.GH_TOKEN }}
path: website-repo
fetch-depth: 0

- name: Build javadocs for specific branches
run: |
# Get branches to process (exclude release-0.7 and earlier)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should checkout apache/fluss first?

BRANCHES=$(git branch -r | grep -E "(origin/main|origin/release-[0-9]+\.[0-9]+)$" | sed 's|origin/||' | grep -v -E "release-0\.[0-7]$" | sort)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move the shell script into .sh file for better maintenance?

I think maybe we can create 2 script files, the first is check_javadoc_branches.sh, the second is push_javadoc_branches.sh.

  • check_javadoc_branches.sh: checks what branches need to build, if no branches to build, then skip the second step.
  • push_javadoc_branches.sh: accept branches to build as parameters, and build javadocs & push the changes to the corresponding javadoc_<version> branches.
  • exit 1 if there is any errors

This makes the action results more visible for skipped branches and errors.

echo "Processing branches: $BRANCHES"
for branch in $BRANCHES; do
echo "=== Processing branch: $branch ==="
# Determine version
if [[ "$branch" == "main" ]]; then
VERSION="main"
elif [[ "$branch" =~ ^release-([0-9]+\.[0-9]+)$ ]]; then
VERSION="${BASH_REMATCH[1]}"
else
echo "Skipping unknown branch format: $branch"
continue
fi
echo "Version: $VERSION"
# Skip if no recent commits (last 7 days)
LAST_COMMIT=$(git log -1 --format="%ct" origin/$branch)
DAYS_AGO=$(( ($(date +%s) - LAST_COMMIT) / 86400 ))
if [[ $DAYS_AGO -gt 7 ]]; then
echo "Skipping $branch - no commits in last 7 days"
continue
fi
# Checkout branch and build javadocs
git checkout $branch
chmod +x ./website/build_javadocs.sh
./website/build_javadocs.sh
# Verify javadocs were generated
if [[ ! -d "website/static/javadoc/$VERSION" ]]; then
echo "Error: Javadocs not generated for $VERSION"
continue
fi
# Copy to website repository
JAVADOC_BRANCH="javadoc-$VERSION"
cd website-repo
# Create or checkout javadoc branch
if git ls-remote --heads origin "$JAVADOC_BRANCH" | grep -q "$JAVADOC_BRANCH"; then
git checkout -B "$JAVADOC_BRANCH" "origin/$JAVADOC_BRANCH"
else
git checkout --orphan "$JAVADOC_BRANCH"
git rm -rf . 2>/dev/null || true
fi
# Copy javadocs directly to root of javadoc branch
cp -r "../website/static/javadoc/$VERSION"/* ./ 2>/dev/null || true
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using cp -r */ can be unreliable with hidden files and may fail if the directory is empty. Consider using cp -r "../website/static/javadoc/$VERSION/." ./ or add a check for directory contents before copying.

Suggested change
cp -r "../website/static/javadoc/$VERSION"/* ./ 2>/dev/null || true
cp -r "../website/static/javadoc/$VERSION"/. ./ 2>/dev/null || true

Copilot uses AI. Check for mistakes.
# Commit and push if there are changes
git add .
if ! git diff --staged --quiet; then
git commit -m "Update javadocs for $VERSION"
git push origin "$JAVADOC_BRANCH"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make it simple to just force push the branch without checking changes. This can avoid some potential bugs or performance issues as the javadocs change is huge.

echo "Updated javadocs for $VERSION"
else
echo "No changes for $VERSION"
fi
cd ..
done
14 changes: 14 additions & 0 deletions .github/workflows/website-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ jobs:
- name: Copy ASF Files
run: |
cp .asf.yaml .htaccess ./build/
- name: Copy Javadocs
run: |
mkdir -p ./javadoc
git clone https://github.com/apache/fluss-website.git temp-website
cd temp-website
for branch in $(git branch -r | grep 'javadoc-' | sed 's/origin\///'); do
version=$(echo "$branch" | sed 's/javadoc-//')
echo "Copying javadocs for version: $version"
git checkout "$branch"
mkdir -p "../javadoc/$version"
cp -r * "../javadoc/$version/" 2>/dev/null || true
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using cp -r * can be unreliable with hidden files and may cause issues if the directory is empty. Consider using cp -r . "../javadoc/$version/" or check if the directory has contents before copying.

Suggested change
cp -r * "../javadoc/$version/" 2>/dev/null || true
cp -r . "../javadoc/$version/" 2>/dev/null || true

Copilot uses AI. Check for mistakes.
done
cd ..
rm -rf temp-website
- name: Deploy website
env:
GIT_USER: gh-actions
Expand Down