Skip to content

Merge pull request #3553 from meilisearch/fix/hybrid-search-mermaid-c… #154

Merge pull request #3553 from meilisearch/fix/hybrid-search-mermaid-c…

Merge pull request #3553 from meilisearch/fix/hybrid-search-mermaid-c… #154

# Actions done after Mintlify deployment following a push done on `main`.
# This will trigger new commits on `main`, so a new deployment of Mintlify.
name: Post Deployment
on:
workflow_dispatch:
schedule:
- cron: '0 23 * * *' # Every day at 11:00 PM UTC
push:
branches:
- 'main'
concurrency:
group: post-deployment
cancel-in-progress: false
jobs:
build-code-samples:
name: Build code samples
runs-on: ubuntu-latest
outputs:
run_openapi_automation: ${{ steps.openapi_automation.outputs.run }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_TOKEN }}
- name: Get OpenAPI automation flag from docs.json
id: openapi_automation
run: |
value=$(jq -r '.. | select(type == "object" and has("internal-meili-fetch-automation")) | .["internal-meili-fetch-automation"] | select(. != null) | tostring' docs.json 2>/dev/null | head -1)
echo "run=${value:-false}" >> "$GITHUB_OUTPUT"
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm install
- name: Generate code sample snippets
run: npm run generate-code-sample-snippets-file
- name: Check for changes
id: changes
run: |
if git diff --quiet snippets/; then
echo "has_changes=false" >> "$GITHUB_ENV"
else
echo "has_changes=true" >> "$GITHUB_ENV"
fi
- name: Commit changes
run: |
if [[ $has_changes == "true" ]]; then
echo "There are changes in the Git working directory."
git config user.name "meili-bot"
git config user.email "robot@meilisearch.com"
git add snippets/
git commit -m "[AUTOMATION POST DEPLOYMENT] Update code samples"
git push origin main
else
echo "No changes in the Git working directory."
fi
# We need to wait for build-code-samples to commit first so we can push a separate commit
# (avoid stacking both changes in one run and keep history clear).
# Only runs when docs.json has "internal-meili-fetch-automation": true.
# In case of issues with the latest release OpenAPI file: fetch the desired OpenAPI file
# manually, then set "internal-meili-fetch-automation" to false to prevent this automation from running.
fetch-openapi-file:
name: Fetch OpenAPI file from Meilisearch release
runs-on: ubuntu-latest
needs: build-code-samples
if: needs.build-code-samples.outputs.run_openapi_automation == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: main
token: ${{ secrets.GH_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm install
- name: Fetch latest meilisearch-openapi.json from Meilisearch release
run: npm run fetch-meilisearch-openapi-file
- name: Check for changes
id: openapi_changes
run: |
if git diff --quiet assets/open-api/meilisearch-openapi.json; then
echo "has_changes=false" >> "$GITHUB_ENV"
else
echo "has_changes=true" >> "$GITHUB_ENV"
fi
- name: Commit changes
run: |
if [[ $has_changes == "true" ]]; then
echo "There are changes in the OpenAPI file."
git config user.name "meili-bot"
git config user.email "robot@meilisearch.com"
git add assets/open-api/meilisearch-openapi.json
git commit -m "[AUTOMATION POST DEPLOYMENT] Update meilisearch-openapi.json from latest Meilisearch release"
git push origin main
else
echo "No changes in the OpenAPI file."
fi
# Runs after fetch-openapi-file: generate Mintlify OpenAPI file, validate with mint openapi-check, commit if valid.
generate-and-check-mintlify-openapi:
name: Generate and check Mintlify OpenAPI file
runs-on: ubuntu-latest
needs: [build-code-samples, fetch-openapi-file]
if: needs.build-code-samples.outputs.run_openapi_automation == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: main
token: ${{ secrets.GH_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm install
- name: Generate Mintlify OpenAPI file
run: npm run generate-mintlify-openapi-file
- name: Validate OpenAPI with Mintlify CLI
run: npx mint openapi-check assets/open-api/meilisearch-openapi-mintlify.json
- name: Check for changes
id: mintlify_changes
run: |
if git diff --quiet assets/open-api/meilisearch-openapi-mintlify.json; then
echo "has_changes=false" >> "$GITHUB_ENV"
else
echo "has_changes=true" >> "$GITHUB_ENV"
fi
- name: Commit changes
run: |
if [[ $has_changes == "true" ]]; then
echo "There are changes in the Mintlify OpenAPI file."
git config user.name "meili-bot"
git config user.email "robot@meilisearch.com"
git add assets/open-api/meilisearch-openapi-mintlify.json
git commit -m "[AUTOMATION POST DEPLOYMENT] Update meilisearch-openapi-mintlify.json"
git push origin main
else
echo "No changes in the Mintlify OpenAPI file."
fi
# After the Mintlify OpenAPI file is updated, check if any new routes are missing
# from docs.json. If so, open a GitHub issue (unless one is already open).
check-undocumented-routes:
name: Open issue for undocumented API routes
runs-on: ubuntu-latest
needs: [build-code-samples, generate-and-check-mintlify-openapi]
if: needs.build-code-samples.outputs.run_openapi_automation == 'true'
permissions:
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: main
token: ${{ secrets.GH_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm install
- name: Check for undocumented routes
id: coverage
run: |
set +e
output=$(npm run check-openapi-routes-coverage 2>&1)
status=$?
set -e
echo "$output"
missing=$(echo "$output" | grep '^\s*-' | sed 's/^\s*- //' || true)
if [ -n "$missing" ]; then
echo "has_missing=true" >> "$GITHUB_OUTPUT"
{
echo "missing_routes<<EOF"
echo "$missing"
echo "EOF"
} >> "$GITHUB_OUTPUT"
else
if [ "$status" -ne 0 ]; then
exit "$status"
fi
echo "has_missing=false" >> "$GITHUB_OUTPUT"
fi
- name: Check for existing open issue
if: steps.coverage.outputs.has_missing == 'true'
id: existing
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
count=$(gh issue list --search "New API routes need documentation in:title" --state open --json number --jq 'length')
echo "open_issues=$count" >> "$GITHUB_OUTPUT"
- name: Create issue for undocumented routes
if: steps.coverage.outputs.has_missing == 'true' && steps.existing.outputs.open_issues == '0'
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
MISSING_ROUTES: ${{ steps.coverage.outputs.missing_routes }}
run: |
# Build the route list as markdown
route_list=""
while IFS= read -r route; do
route_list="${route_list}- \`${route}\`
"
done <<< "$MISSING_ROUTES"
gh issue create \
--title "New API routes need documentation" \
--body "The OpenAPI spec was updated and the following routes are not yet documented in \`docs.json\`:
${route_list}
**Next steps:**
1. Add the missing route(s) to \`docs.json\` under the appropriate API reference group
2. Run \`npm run check-openapi-routes-coverage\` to verify
_This issue was created automatically by the post-deployment workflow._"
# Runs alongside the OpenAPI automation. A new Meilisearch release triggers both
# the OpenAPI update and the changelog update at the same time.
# Only runs when docs.json has "internal-meili-fetch-automation": true.
update-changelog:
name: Update changelog if new release exists
runs-on: ubuntu-latest
needs: [build-code-samples]
if: needs.build-code-samples.outputs.run_openapi_automation == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: main
token: ${{ secrets.GH_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm install
- name: Generate changelog
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: npm run generate-changelog
- name: Commit changes
run: |
if git diff --quiet changelog/; then
echo "No changelog changes detected."
else
git config user.name "meili-bot"
git config user.email "robot@meilisearch.com"
git add changelog/
git commit -m "[AUTOMATION POST DEPLOYMENT] Update changelog with latest Meilisearch release"
git push origin main
fi