Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
43d2d3d
push files to the branch that will be merged in
alan707 Oct 19, 2025
0a1dbf5
create scripts to run github actions workflow locally and debug
alan707 Oct 19, 2025
49405cc
fixed copy-upstream-docs.sh and cleaup-mdx.sh
alan707 Oct 19, 2025
5957221
git pull first
alan707 Oct 19, 2025
83305dd
test new strategy
alan707 Oct 19, 2025
79cfe44
don't use rebase
alan707 Oct 19, 2025
9abe21d
chore: update documentation from upstream Bazel repo
github-actions[bot] Oct 19, 2025
584f099
attempt to re-trigger workflow after commit is auto-pushed
alan707 Oct 19, 2025
918f0aa
remove go.mod, go.sum and binary from repo
alan707 Oct 20, 2025
ccf34f6
now ignore them
alan707 Oct 20, 2025
c7c21d1
fix those files later
alan707 Oct 20, 2025
b3a9e08
chore: update documentation from upstream Bazel repo
github-actions[bot] Oct 20, 2025
3882d6d
revert docs.json.update.sh
alan707 Oct 20, 2025
c07b2e8
fix some files
alan707 Oct 20, 2025
64da6b3
chore: update documentation from upstream Bazel repo
github-actions[bot] Oct 20, 2025
252abdf
add more broken files
alan707 Oct 20, 2025
ea38ca2
chore: update documentation from upstream Bazel repo
github-actions[bot] Oct 20, 2025
3f51242
Merge branch 'main' into alan/convert_after_submodule_update
alan707 Oct 29, 2025
27ca9c5
chore: update documentation from upstream Bazel repo
github-actions[bot] Oct 29, 2025
1b172ee
ignore more broken files
alan707 Oct 29, 2025
5c4b9d4
clean upstream before pushing changes
alan707 Oct 29, 2025
7f1e2ed
chore: update documentation from upstream Bazel repo
github-actions[bot] Oct 29, 2025
9691049
make pull from bazel build a callable workflow
alan707 Oct 29, 2025
ef24d27
fix typo
alan707 Oct 29, 2025
f8cae4b
renove packages
alan707 Oct 29, 2025
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
38 changes: 28 additions & 10 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,45 @@ concurrency:
cancel-in-progress: false

jobs:
automerge:
timeout-minutes: 10
# Only run on Dependabot PRs targeting main
check-dependabot:
timeout-minutes: 5
if: >
github.event.pull_request.user.login == 'dependabot[bot]' &&
github.event.pull_request.base.ref == 'main'
runs-on: ubuntu-latest
outputs:
should_process: ${{ steps.check.outputs.should_process }}
steps:
- name: Fetch Dependabot metadata
id: meta
uses: dependabot/fetch-metadata@v2
with:
# already added to repo
github-token: ${{ secrets.GH_AUTOMERGE_PAT }}

# Gate: only submodules updates; only the "upstream" submodule path
- name: Check if upstream submodule
id: check
run: |
if [[ "${{ steps.meta.outputs.package-ecosystem }}" == "submodules" ]] && \
[[ "${{ steps.meta.outputs.dependency-names }}" == *"upstream"* ]]; then
echo "should_process=true" >> $GITHUB_OUTPUT
else
echo "should_process=false" >> $GITHUB_OUTPUT
fi

# Generate docs after dependabot updates the submodule
generate-docs:
needs: check-dependabot
if: needs.check-dependabot.outputs.should_process == 'true'
uses: ./.github/workflows/pull-from-bazel-build.yml
secrets: inherit

# Auto-merge after docs are generated
enable-automerge:
needs: [check-dependabot, generate-docs]
if: needs.check-dependabot.outputs.should_process == 'true'
runs-on: ubuntu-latest
steps:
- name: Enable auto-merge (squash)
if: >
steps.meta.outputs.package-ecosystem == 'submodules' &&
contains(steps.meta.outputs.dependency-names, 'upstream')
run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"
env:
# already added to repo
GH_TOKEN: ${{ secrets.GH_AUTOMERGE_PAT }}
GH_TOKEN: ${{ secrets.GH_AUTOMERGE_PAT }}
20 changes: 20 additions & 0 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Generate Documentation on PR

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

permissions:
contents: write
pull-requests: write

concurrency:
group: generate-docs-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
generate-docs:
# Skip Dependabot PRs (handled by auto-merge workflow)
if: github.event.pull_request.user.login != 'dependabot[bot]'
uses: ./.github/workflows/pull-from-bazel-build.yml
secrets: inherit
195 changes: 112 additions & 83 deletions .github/workflows/pull-from-bazel-build.yml
Original file line number Diff line number Diff line change
@@ -1,107 +1,136 @@
name: Pull Bazel Build Upstream Repo
name: Pull Fresh Upstream Documentation

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
bazelCommitHash:
description: 'Specific Bazel commit hash to checkout (optional)'
required: false
type: string
default: ''

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
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v5
with:
# Don't auto-init submodules
submodules: false
- name: Checkout repository
uses: actions/checkout@v5
with:
# Don't auto-init submodules
submodules: false
# This token is necessary so that the action can push into the repo
# and trigger the required check (this workflow). Otherwise, the
# default GITHUB_TOKEN cannot be considered a 'synchronize' event
token: ${{ secrets.GH_AUTOMERGE_PAT }}

- name: Checkout submodules
run: git submodule update --init -- upstream
- 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: 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: 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
- 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: 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: Clean up mdx files
run: ./cleanup-mdx.sh

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.2'
- 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: 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: 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: 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 upstream docs to mdx
run: ./copy-upstream-docs.sh
- name: Transform upstream docs to mdx
run: ./copy-upstream-docs.sh

- name: Create versioned navigation
run: ./docs.json.update.sh
- name: Create versioned navigation
run: ./docs.json.update.sh

- name: Clean up temporary files
run: rm -rf reference-docs-temp
- name: Clean up temporary files
run: rm -rf reference-docs-temp

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Commit and push changes
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
set -euo pipefail

# Ensure local branch points at origin/BRANCH and is checked out
git fetch origin "$BRANCH"
git switch -C "$BRANCH" "origin/$BRANCH"
git branch --set-upstream-to="origin/$BRANCH" "$BRANCH"

# Rebase onto latest remote before creating a new commit
git pull

# Clean up any modified content in submodules (keep pointer changes)
# This handles the "modified content" issue while preserving submodule commit updates
cd upstream
git reset --hard
git clean -fd
cd ..

if [[ -n "$(git status --porcelain)" ]]; then
echo "Changes detected, committing and pushing..."
git add -A
git commit -m $'chore: update documentation from upstream Bazel repo\n\nGenerated by GitHub Actions workflow from upstream Bazel repository.\nThis commit includes transformed documentation files ready for Mintlify deployment.'

# Push back to the same branch
git push origin "HEAD:$BRANCH"
echo "Changes committed and pushed successfully"
else
echo "No changes detected, skipping commit"
fi
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ __pycache__/
.venv/
.hugo_build.lock
node_modules
# ignore go build files
html2md_converter/go.sum
html2md_converter/go.mod
html2md_converter/html-to-md
2 changes: 1 addition & 1 deletion basics/hermeticity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ non-hermetic actions.
rich enough to allow arbitrary processing to happen in the process. You can
get a log of some potentially non-hermetic actions in Bazel workspace rules by
adding the flag
`--experimental_workspace_rules_log_file={{ '<var>' }}PATH{{ '</var>' }}` to
`--experimental_workspace_rules_log_file=<var>PATH</var>` to
your Bazel command.

Note: Make your build fully hermetic when mixing remote and local execution,
Expand Down
7 changes: 5 additions & 2 deletions cleanup-mdx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ LOCAL_FILES="

echo "Cleaning up .mdx files..."

# Find all .mdx files in the repo (excluding upstream, work, .github, .cursor directories)
find . -name "*.mdx" -type f | while read -r mdx_file; do
# Find all .mdx files in the repo, excluding versioned directories
# This excludes any directory starting with a digit (e.g., 6.5.0, 7.6.1, 8.0.1)
find . -name "*.mdx" -type f \
-not -path "./[0-9]*/*" \
-not -path "./.github/*" | while read -r mdx_file; do

# Check if this exact file path is in LOCAL_FILES
if echo "$LOCAL_FILES" | grep -q "^\s*$mdx_file\s*$"; then
Expand Down
Loading
Loading