Fix issue #44 #88
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| # Don't auto-init submodules | |
| submodules: false | |
| fetch-depth: 0 # Fetch all history for all branches and tags | |
| - 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: 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 upstream docs to mdx | |
| run: ./copy-upstream-docs.sh | |
| - name: Create versioned navigation | |
| run: ./docs.json.update.sh | |
| - name: Clean up temporary files | |
| run: rm -rf reference-docs-temp | |
| - name: Commit & Push generated MDX | |
| run: | | |
| # configure git identity | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| # Stage changes: new, modifications, deletions | |
| git add -A '*.mdx' | |
| # Check if any mdx files changed | |
| if git diff --cached --exit-code; then | |
| echo "No MDX changes to commit" | |
| else | |
| echo "Committing MDX doc updates" | |
| git commit -m "Auto-generate MDX docs" | |
| # push back to this branch | |
| # github.ref is like "refs/heads/branch" | |
| branch="${{ github.ref_name }}" | |
| echo "Pushing to branch: $branch" | |
| git push origin HEAD:$branch | |
| fi |