Skip to content

Fix issue #44

Fix issue #44 #83

name: Pull Bazel Build Upstream Repo
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [main]
# called from trigger-from-bazel-repo.yml
workflow_dispatch:
inputs:
bazelCommitHash:
description: 'The commit hash of the Bazel repo to use'
type: string
default: origin/main
# allow debugging by triggering from the GitHub UI
workflow_call:
inputs:
bazelCommitHash:
description: 'The commit hash of the Bazel repo to use'
type: string
default: origin/main
jobs:
pull-fresh-upstream:
# don't run on dependabot PRs
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v5
with:
# Don't auto-init submodules
submodules: false
- name: Checkout submodules
run: git submodule update --init -- upstream
- name: Checkout commit of Bazel Build submodule
if: ${{ inputs.bazelCommitHash != '' }}
working-directory: upstream
run: git checkout '${{ inputs.bazelCommitHash }}'
- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.15.0
with:
bazelisk-cache: true
repository-cache: true
- name: Build reference documentation
working-directory: upstream
run: >
bazel build
--config=docs
--build_metadata=ROLE=DOCS
--remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_ORG_API_KEY }}
--bes_results_url=https://app.buildbuddy.io/invocation/
--bes_backend=grpcs://remote.buildbuddy.io
--remote_cache=grpcs://remote.buildbuddy.io
--remote_timeout=10m
//src/main/java/com/google/devtools/build/lib:gen_reference_docs
# Upload reference-docs.zip as an artifact for debugging purposes
- name: Upload reference docs artifact
if: ${{ github.ref != 'refs/heads/main' }}
uses: actions/upload-artifact@v4.6.2
with:
name: reference-docs
path: upstream/bazel-bin/src/main/java/com/google/devtools/build/lib/reference-docs.zip
retention-days: 7
- name: Clean up mdx files
run: ./cleanup-mdx.sh
- name: Transform upstream docs to mdx
run: ./copy-upstream-docs.sh
- name: Create versioned navigation
run: ./docs.json.update.sh
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.2'
- name: Initialize Go module for converter
run: |
cd html2md_converter
go mod init html-to-md-converter
go get github.com/JohannesKaufmann/html-to-markdown
- name: Build HTML to Markdown converter
run: |
cd html2md_converter
go build -o html-to-md main.go
- name: Convert reference documentation HTML to Markdown
run: |
# Extract and convert HTML reference docs to Markdown
./html2md_converter/html-to-md \
-zip upstream/bazel-bin/src/main/java/com/google/devtools/build/lib/reference-docs.zip \
-output reference-docs-temp
- name: Transform reference docs to MDX
run: |
# Process reference/ directory
find reference-docs-temp/reference -name "*.md" -type f | while read -r file; do
# Extract path relative to reference-docs-temp/
rel_path="${file#reference-docs-temp/}"
output_file="$rel_path"
output_file="${output_file%.md}.mdx"
mkdir -p "$(dirname "$output_file")"
awk -f transform-docs.awk "$file" > "$output_file"
done
# Copy YAML files
find reference-docs-temp/reference -name "*.yaml" -type f | while read -r file; do
rel_path="${file#reference-docs-temp/}"
output_file="$rel_path"
mkdir -p "$(dirname "$output_file")"
cp "$file" "$output_file"
done
- name: Transform rules docs to MDX
run: |
# Process rules/ directory
find reference-docs-temp/rules -name "*.md" -type f | while read -r file; do
# Extract path relative to reference-docs-temp/
rel_path="${file#reference-docs-temp/}"
output_file="$rel_path"
output_file="${output_file%.md}.mdx"
mkdir -p "$(dirname "$output_file")"
awk -f transform-docs.awk "$file" > "$output_file"
done
# Copy YAML files
find reference-docs-temp/rules -name "*.yaml" -type f | while read -r file; do
rel_path="${file#reference-docs-temp/}"
output_file="$rel_path"
mkdir -p "$(dirname "$output_file")"
cp "$file" "$output_file"
done
- name: Clean up temporary files
run: rm -rf reference-docs-temp