✅ | backport-55-245d618d159c9dd77237b89b310f82bc6b049d1e
-> release-x.55.x
#1191
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: Process Docs Changes | |
on: | |
workflow_dispatch: | |
inputs: | |
source_branch: | |
description: metabase/metabase branch triggered this workflow | |
required: true | |
type: string | |
target_branch: | |
description: metabase/metabase target branch name | |
required: true | |
type: string | |
annotation: | |
description: note to describe what the pr does | |
required: false | |
type: string | |
default: "auto-build" | |
dispatch_type: | |
description: 'Type of dispatch action to simulate' | |
required: false | |
default: 'docs_update' | |
type: choice | |
options: | |
- docs_update | |
- docs_merge | |
- docs_close | |
pr_number: | |
description: 'Number of the PR in metabase/metabase that triggered this action' | |
required: false | |
type: number | |
update_dirs: | |
description: comma delimited paths to git add into the generated PR | |
required: false | |
type: string | |
default: "" | |
repository_dispatch: | |
types: [docs_update, docs_merge, docs_close] | |
run-name: >- | |
${{ | |
(github.event.action == 'docs_merge' || github.event.inputs.dispatch_type == 'docs_merge') && '✅' || | |
(github.event.action == 'docs_update' || github.event.inputs.dispatch_type == 'docs_update') && '🔄' || | |
(github.event.action == 'docs_close' || github.event.inputs.dispatch_type == 'docs_close') && '🗑️' | |
}}${{ | |
(github.event.inputs.annotation || github.event.client_payload.annotation) && | |
format(' | `{0}` | ', github.event.inputs.annotation || github.event.client_payload.annotation) || | |
' | ' | |
}}`${{ github.event.inputs.source_branch || github.event.client_payload.source_branch }}` -> `${{ github.event.inputs.target_branch || github.event.client_payload.target_branch }}` | |
jobs: | |
build: | |
name: >- | |
`${{ github.event.inputs.source_branch || github.event.client_payload.source_branch }}` -> ${{ github.event.inputs.target_branch || github.event.client_payload.target_branch }} | ${{ github.event.action || github.event.inputs.dispatch_type }} | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }} | |
MAIN_REPO_SOURCE_BRANCH: "${{ github.event.inputs.source_branch || github.event.client_payload.source_branch }}" | |
MAIN_REPO_TARGET_BRANCH: "${{ github.event.inputs.target_branch || github.event.client_payload.target_branch }}" | |
ANNOTATION: "${{ github.event.inputs.annotation || github.event.client_payload.annotation || 'auto-build' }}" | |
PR_NUMBER: "${{ github.event.inputs.pr_number || github.event.client_payload.pr_number }}" | |
UPDATE_DIRS: "${{ github.event.inputs.update_dirs || github.event.client_payload.update_dirs }}" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' # See 'Supported distributions' for available options | |
java-version: '21' | |
- name: Install Clojure (needed to build cljs for SDK dox generation) | |
uses: DeLaGuardo/[email protected] | |
with: | |
cli: 1.12.0.1530 | |
bb: 1.12.200 | |
- name: Check for PR Close | |
id: check | |
if: | | |
(github.event_name == 'repository_dispatch' && github.event.action == 'docs_close') || | |
(github.event_name == 'workflow_dispatch' && github.event.inputs.dispatch_type == 'docs_close') | |
run: | | |
gh pr close "${MAIN_REPO_SOURCE_BRANCH}->${MAIN_REPO_TARGET_BRANCH}" --repo metabase/docs.metabase.github.io --delete-branch | |
echo "skip=true" >> "$GITHUB_OUTPUT" | |
- name: Run docs repo build tests | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
bb script/_test/all.clj | |
- name: Filter non-documented branches | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
bb script/check_incoming_branchname.clj --target-branch "$MAIN_REPO_TARGET_BRANCH" | |
- name: Setup Node.js | |
if: steps.check.outputs.skip != 'true' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22' | |
- name: Install js dependencies | |
if: steps.check.outputs.skip != 'true' | |
run: yarn install --frozen-lockfile --prefer-offline | |
- name: Set up Ruby # uses version from .ruby-version | |
if: steps.check.outputs.skip != 'true' | |
uses: ruby/setup-ruby@d5fb7a202fc07872cb44f00ba8e6197b70cb0c55 # v1.179.0 | |
with: | |
bundler-cache: true | |
- name: Install ruby dependencies | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
bundle install | |
- name: Setup Git Authenticatation | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
git config --global user.name "Metabase Docs bot" | |
git config --global user.email "[email protected]" | |
git remote set-url origin "https://x-access-token:${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}@github.com/metabase/docs.metabase.github.io.git" | |
# observed this failing during sdk docs generation deps downloads, so adding retry logic | |
- name: Update docs for branchname | |
uses: nick-fields/retry@v3 | |
if: | | |
(steps.check.outputs.skip != 'true' && | |
((github.event_name == 'repository_dispatch' && github.event.action == 'docs_update') || | |
(github.event_name == 'workflow_dispatch' && github.event.inputs.dispatch_type == 'docs_update'))) | |
with: | |
timeout_minutes: 20 | |
max_attempts: 3 | |
retry_on: error | |
command: | | |
bb script/update_docs_for_branchname.clj --source-branch "$MAIN_REPO_SOURCE_BRANCH" --target-branch "$MAIN_REPO_TARGET_BRANCH" | |
- name: Cleanup cloud docs (move them to latest, remove from all other versions) | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
bb script/cleanup_cloud_docs.clj | |
- name: Checkout Control files from Marketing Repo | |
if: steps.check.outputs.skip != 'true' | |
uses: actions/checkout@v4 | |
with: | |
repository: metabase/metabase.github.io | |
ref: master | |
path: .marketing_repo | |
token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }} | |
- name: Merge control files from Marketing Repo | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
bb script/sync_repo.clj --from-repo .marketing_repo | |
- name: "yarn lint-markdown" | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
yarn lint-markdown | |
- name: "yarn lint-styles" | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
yarn lint-styles | |
- name: "yarn lint-scripts" | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
yarn lint-scripts | |
- name: "yarn lint-links" | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
yarn lint-links | |
- name: Build the Jekyll Site | |
if: steps.check.outputs.skip != 'true' | |
env: | |
JEKYLL_ENV: production | |
NODE_ENV: production | |
run: | | |
# Clear the existing site: | |
rm -rf _site | |
# Build the jekyll site: | |
script/build | |
- name: Run htmlproofer + metabase.com-aware link checks | |
if: steps.check.outputs.skip != 'true' | |
run: | | |
SECONDS=0 | |
script/links || true | |
echo "htmlproofer took: ${SECONDS} seconds." | |
echo 'checking reported links...' | |
echo "htmlproofer spit out a report of length: $(wc -l < htmlproofer.out)" | |
bb script/analyze_links.clj --htmlproofer-output htmlproofer.out --limit 1 | |
- name: Update or Create the Pull Request | |
if: | | |
(steps.check.outputs.skip != 'true' && | |
((github.event_name == 'repository_dispatch' && github.event.action == 'docs_update') || | |
(github.event_name == 'workflow_dispatch' && github.event.inputs.dispatch_type == 'docs_update'))) | |
run: | | |
bb script/update_or_create_pr.clj \ | |
--source-branch "$MAIN_REPO_SOURCE_BRANCH" \ | |
--target-branch "$MAIN_REPO_TARGET_BRANCH" \ | |
--annotation "$ANNOTATION" \ | |
--pr-number "$PR_NUMBER" \ | |
--update-dirs "$UPDATE_DIRS" | |
- name: Remove control files from Marketing Repo | |
run: | | |
bb script/sync_repo.clj --delete | |
- name: Merge Updated Docs | |
if: | | |
(steps.check.outputs.skip != 'true' && | |
((github.event_name == 'repository_dispatch' && github.event.action == 'docs_merge') || | |
(github.event_name == 'workflow_dispatch' && github.event.inputs.dispatch_type == 'docs_merge'))) | |
run: | | |
bb script/merge.clj --source-branch "$MAIN_REPO_SOURCE_BRANCH" --target-branch "$MAIN_REPO_TARGET_BRANCH" |