Skip to content

on-bcr-trigger

on-bcr-trigger #1508

# Deploys the BCR frontend SPA to GitHub Pages via the separate
# bazel-contrib/bcr-frontend-site repository.
#
# Required secrets (configured in the "deploy" environment):
#
# BCR_AUTOMATION_TOKEN - GitHub PAT with read access to this repo and its
# submodules. Used for checkout and submodule fetch.
#
# GHPAGES_TOKEN - GitHub PAT with contents:write permission scoped to
# the bazel-contrib/bcr-frontend-site repository.
# Used to force-push deployed assets to that repo's
# main branch. This should be a fine-grained PAT
# limited to only the bcr-frontend-site repo.
name: Deploy to GitHub Pages
on:
repository_dispatch:
types: [on-bcr-trigger]
workflow_dispatch:
inputs:
bcr_commit:
description: "BCR commit SHA to deploy (defaults to latest)"
required: false
type: string
docs_all_versions:
description: "Generate docs for all versions (not just latest)"
required: false
type: boolean
default: false
docs_module_filter:
description: "Comma-separated module name prefixes (e.g. 'rules_,bazel_')"
required: false
type: string
workflow_call:
inputs:
bcr_commit:
required: false
type: string
docs_all_versions:
required: false
type: boolean
default: false
docs_module_filter:
required: false
type: string
secrets:
BCR_AUTOMATION_TOKEN:
required: true
concurrency:
group: ghpages-deploy
cancel-in-progress: false
jobs:
deploy:
runs-on: self-hosted
environment: deploy
permissions:
contents: read
packages: write
env:
GITHUB_TOKEN: ${{ secrets.BCR_AUTOMATION_TOKEN }}
DEPLOY_REMOTE: https://x-access-token:${{ secrets.BCR_AUTOMATION_TOKEN }}@github.com/bazel-contrib/bcr-frontend-site.git
steps:
- uses: actions/checkout@v6
with:
ref: main
submodules: true
token: ${{ secrets.BCR_AUTOMATION_TOKEN }}
- name: Determine BCR commit
id: bcr
run: |
if [ -n "${{ inputs.bcr_commit }}" ]; then
BCR_SHA="${{ inputs.bcr_commit }}"
elif [ -n "${{ github.event.client_payload.bcrCommitHash }}" ]; then
BCR_SHA="${{ github.event.client_payload.bcrCommitHash }}"
else
# Get latest BCR commit
cd data/bazel-central-registry
git fetch origin main
BCR_SHA=$(git rev-parse origin/main)
cd ../..
fi
echo "sha=$BCR_SHA" >> $GITHUB_OUTPUT
echo "Deploying BCR commit: $BCR_SHA"
- name: Update submodule to target commit
run: |
cd data/bazel-central-registry
git fetch origin
git checkout ${{ steps.bcr.outputs.sha }}
cd ../..
echo "Updated submodule to ${{ steps.bcr.outputs.sha }}"
- uses: bazel-contrib/setup-bazel@0.19.0
- name: Clean and initialize BCR
run: make bcr_clean bcr_init bcr_update
- name: Build gazelle flags
id: gazelle
run: |
EXTRA_FLAGS=""
if [ "${{ inputs.docs_all_versions }}" = "true" ]; then
EXTRA_FLAGS="--docs-all-versions --docs-site-repo=https://github.com/bazel-contrib/bcr-frontend-site.git"
fi
if [ -n "${{ inputs.docs_module_filter }}" ]; then
EXTRA_FLAGS="$EXTRA_FLAGS --docs-module-filter=${{ inputs.docs_module_filter }}"
fi
echo "extra_flags=$EXTRA_FLAGS" >> $GITHUB_OUTPUT
- name: Run BCR gazelle
run: >-
bazelisk
--bazelrc=.github/workflows/ci.bazelrc
--bazelrc=.bazelrc
run
//:bcr
--
${{ steps.gazelle.outputs.extra_flags }}
- name: Deploy to GitHub Pages
run: >-
bazelisk
--bazelrc=.github/workflows/ci.bazelrc
--bazelrc=.bazelrc
run
--config=ci
--//app/bcr:release_type=production
--//app/bcr:prerender_modules=on
//app/bcr:ghpages
- name: Log deployment
run: |
echo "Deployed BCR commit ${{ steps.bcr.outputs.sha }} to GitHub Pages"