Skip to content

Merge pull request #423 from flashcatcloud/feat/ai-sre #329

Merge pull request #423 from flashcatcloud/feat/ai-sre

Merge pull request #423 from flashcatcloud/feat/ai-sre #329

Workflow file for this run

# Publish the docs for AI Q&A: sync them into Meilisearch, and publish
# flashduty-docs.tar.gz (the same docs as Markdown files, plus the OpenAPI
# specs and glossary) for tools that grep and read the docs directly.
#
# The Meilisearch sync covers the whole doc set: all docs are upserted and
# index documents whose source file is gone are deleted.
#
# Uses GitHub Environments for dev/prod separation. Create two environments in
# Settings > Environments: "development" and "production".
#
# Per-environment secrets (all required, keep as secrets to hide Meilisearch endpoint):
# MEILI_ENDPOINT - Meilisearch instance URL
# MEILI_API_KEY - API key with documents read/write permission
# MEILI_INDEX - Target index name
# Repository secrets for the tarball: CDN_ACCESS_KEY, CDN_SECRET_KEY,
# CDN_BUCKET, CDN_REGION, CDN_ENDPOINT.
#
# Branch mapping: main -> production (https://docs-cdn.flashcat.cloud/docs/),
# test -> development (https://docs-cdn.flashcat.cloud/test/docs/)
name: Publish docs for AI search
on:
push:
branches: [main, test]
paths:
- 'zh/**'
- 'en/**'
- 'docs.json'
- 'api-reference/**'
- 'glossary.md'
- 'integration-docs/scripts/*docs-bundle*'
- 'integration-docs/scripts/oss-cdn.mjs'
- 'integration-docs/scripts/cdn-url.mjs'
- 'integration-docs/package.json'
- '.github/workflows/upload.yml'
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
default: 'production'
type: choice
options:
- production
- development
jobs:
upload:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production' || 'development') }}
# One sync per index at a time: an older run listing the index while a
# newer one uploads would delete the newer run's added docs.
concurrency:
group: meilisearch-upload-${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production' || 'development') }}
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq
jq --version
- name: Upload to Meilisearch
env:
MEILI_ENDPOINT: ${{ secrets.MEILI_ENDPOINT }}
MEILI_API_KEY: ${{ secrets.MEILI_API_KEY }}
MEILI_INDEX: ${{ secrets.MEILI_INDEX }}
run: |
chmod +x ./scripts/upload.sh
bash ./scripts/upload.sh
bundle:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production' || 'development') }}
# Every run uploads the whole tarball, so a newer run supersedes an older
# one; cancelling the older keeps it from finishing last with stale docs.
concurrency:
group: docs-bundle-${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production' || 'development') }}
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
working-directory: integration-docs
run: npm install
- name: Test docs bundle scripts
working-directory: integration-docs
run: npm run test:docs-bundle
- name: Build and upload docs bundle
working-directory: integration-docs
env:
CDN_ACCESS_KEY: ${{ secrets.CDN_ACCESS_KEY }}
CDN_SECRET_KEY: ${{ secrets.CDN_SECRET_KEY }}
CDN_BUCKET: ${{ secrets.CDN_BUCKET }}
CDN_REGION: ${{ secrets.CDN_REGION }}
CDN_ENDPOINT: ${{ secrets.CDN_ENDPOINT }}
CDN_URL: 'https://docs-cdn.flashcat.cloud'
CDN_DIR: ${{ (github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production' || 'development')) == 'production' && '/docs' || '/test/docs' }}
run: npm run upload:docs-bundle