Doc Search Scripts (All Stable, Preview Full) #2
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: Doc Search Scripts (All Stable, Preview Full) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| preview_base_url: | |
| description: 'Preview base URL' | |
| required: true | |
| default: 'https://docs.tidb.io/' | |
| type: string | |
| language: | |
| description: 'Language scope for preview full prewarm' | |
| required: true | |
| default: en | |
| type: choice | |
| options: | |
| - both | |
| - en | |
| - zh | |
| preview_runlist: | |
| description: 'Preview runlist file under all-stable/configs' | |
| required: true | |
| default: runlist-preview-full.json | |
| type: string | |
| scraper_repo: | |
| description: 'Docsearch-scraper repo used to patch workflow image' | |
| required: true | |
| default: 'https://github.com/shczhen/docsearch-scraper.git' | |
| type: string | |
| scraper_ref: | |
| description: 'Docsearch-scraper branch/ref used to patch workflow image' | |
| required: true | |
| default: 'incrementalCrawl' | |
| type: string | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: docsearch-all-stable-full-preview | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| ref: 'doc-search' | |
| - name: Login to Container Registry | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ${{ secrets.DOCKER_REGISTRY }} | |
| username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} | |
| password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | |
| - name: Run scripts | |
| run: | | |
| set -o pipefail | |
| cd docsearch | |
| touch .env | |
| echo "APPLICATION_ID=${{ secrets.ALGOLIA_APPLICATION_ID }}" >> .env | |
| echo "API_KEY=${{ secrets.ALGOLIA_API_KEY }}" >> .env | |
| echo "GITHUB_AUTH_TOKEN=${{ secrets.GH_TOKEN }}" >> .env | |
| export GITHUB_AUTH_TOKEN=${{ secrets.GH_TOKEN }} | |
| export CRAWL_LANG="${{ inputs.language }}" | |
| PREVIEW_BASE_URL="${{ inputs.preview_base_url }}" | |
| export CRAWL_LOCAL_URL="${PREVIEW_BASE_URL%/}/" | |
| export PREVIEW_RUNLIST_FILE="${{ inputs.preview_runlist }}" | |
| echo "Run preview full prewarm against: $CRAWL_LOCAL_URL" | |
| echo "Use preview runlist file: $PREVIEW_RUNLIST_FILE" | |
| preview_home_status="$(curl -sS -o /dev/null -w "%{http_code}" "$CRAWL_LOCAL_URL")" | |
| if [ "$preview_home_status" != "200" ]; then | |
| echo "Preview base URL probe failed: $CRAWL_LOCAL_URL (status=$preview_home_status)" | |
| exit 1 | |
| fi | |
| if curl -sS "$CRAWL_LOCAL_URL" | grep -qi "<title>.*404"; then | |
| echo "Preview base URL resolved to a 404 page: $CRAWL_LOCAL_URL" | |
| exit 1 | |
| fi | |
| export BASE_DOCKER_REGISTRY="${{ secrets.DOCKER_REGISTRY }}" | |
| export PATCH_SCRAPER_REPO="${{ inputs.scraper_repo }}" | |
| export PATCH_SCRAPER_REF="${{ inputs.scraper_ref }}" | |
| export PATCHED_DOCKER_REGISTRY="local" | |
| export PATCH_IMAGE_ENV_FILE="/tmp/docsearch-patched-image.env" | |
| ./all-stable/scripts/prepare-patched-scraper-image.sh "$(pwd)/all-stable" | |
| . "$PATCH_IMAGE_ENV_FILE" | |
| export DOCKER_REGISTRY="$PATCHED_DOCKER_REGISTRY" | |
| export ENABLE_CONTAINER_SOURCE_PROBE=true | |
| echo "Run preview full prewarm with patched image: $PATCHED_SCRAPER_IMAGE" | |
| ./all-stable/scripts/crawl-preview-full.sh "$(pwd)/all-stable" 2>&1 | tee /tmp/docsearch-all-stable-full-preview.log | |
| ./all-stable/scripts/check-crawl-errors.sh /tmp/docsearch-all-stable-full-preview.log |