Skip to content

[chore] add required check #41

[chore] add required check

[chore] add required check #41

Workflow file for this run

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
---
name: docs-next build check
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.ref }} (docs-next build)
cancel-in-progress: true
jobs:
build:
name: Build docs-next
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.ref }} ( ${{ github.event.pull_request.head.sha }} )
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Detect relevant changes
id: changes
run: |
set -e
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
CHANGED=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")
echo "Changed files:"
echo "$CHANGED"
if echo "$CHANGED" | grep -E '^(docs-next/|sidebars-next\.ts$|next_versions\.json$|i18n/zh-CN/docusaurus-plugin-content-docs-next/|docusaurus\.config\.js$|\.github/workflows/docs-next-build\.yml$)' >/dev/null; then
echo "relevant=true" >> "$GITHUB_OUTPUT"
else
echo "relevant=false" >> "$GITHUB_OUTPUT"
echo "No docs-next-related changes detected; skipping build."
fi
- name: Use Node.js
if: steps.changes.outputs.relevant == 'true'
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
if: steps.changes.outputs.relevant == 'true'
run: |
npm install -g yarn
yarn install --frozen-lockfile || yarn install
- name: Build (current only, EN + zh-CN)
if: steps.changes.outputs.relevant == 'true'
env:
DOCS_VERSIONS: current
run: |
export NODE_OPTIONS=--max-old-space-size=8192
yarn docusaurus build --locale en --locale zh-CN
- name: Verify docs-next artifacts
if: steps.changes.outputs.relevant == 'true'
run: |
set -e
test -d build/docs-next/dev
test -d build/zh-CN/docs-next/dev
# docs-next 应不在 sitemap
if grep -q "/docs-next/" build/sitemap.xml; then
echo "::error::sitemap.xml contains /docs-next/ entries (should be excluded during graceful rollout)"
exit 1
fi
# robots.txt 应有 Disallow
if ! grep -q "Disallow: /docs-next/" build/robots.txt; then
echo "::error::robots.txt is missing 'Disallow: /docs-next/'"
exit 1
fi
echo "✅ docs-next artifacts verified"