Skip to content

Algolia Index Maintenance #40

Algolia Index Maintenance

Algolia Index Maintenance #40

name: Algolia Index Maintenance
on:
# Run every Monday at 6:00 AM UTC (8:00 AM CET in winter, 7:00 AM CEST in summer)
schedule:
- cron: '0 6 * * 1'
# Allow manual triggering for testing and emergency repairs
workflow_dispatch:
inputs:
collection:
description: 'Collection to repair (or "all" for all collections)'
required: false
default: 'all'
type: choice
options:
- 'all'
- 'podcasts'
- 'meetups'
- 'speakers'
- 'picks_of_the_day'
- 'transcripts'
jobs:
repair-index:
name: Check and Repair Algolia Search Index
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./directus-cms/extensions/directus-extension-programmierbar-bundle
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './directus-cms/extensions/directus-extension-programmierbar-bundle/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Run Algolia Index Repair
env:
PUBLIC_URL: ${{ secrets.PUBLIC_URL }}
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
run: |
COLLECTION="${{ github.event.inputs.collection || 'all' }}"
echo "πŸ”§ Running Algolia index repair for collection: $COLLECTION"
npm run algolia-index-repair "$COLLECTION"
- name: Create Issue on Failure
if: failure()
uses: actions/github-script@v7
with:
script: |
const title = `🚨 Algolia Index Maintenance Failed - ${new Date().toISOString().split('T')[0]}`;
const body = `
## Algolia Index Maintenance Failure
The scheduled Algolia index maintenance failed on ${new Date().toISOString()}.
**Details:**
- **Workflow:** ${context.workflow}
- **Run ID:** ${context.runId}
- **Collection:** ${{ github.event.inputs.collection || 'all' }}
- **Triggered by:** ${context.eventName === 'schedule' ? 'Scheduled run' : 'Manual trigger'}
**Action Required:**
1. Check the [workflow logs](${context.payload.repository.html_url}/actions/runs/${context.runId}) for details
2. Verify environment variables and secrets are properly configured
3. Run the repair manually if needed: \`npm run algolia-index-repair all\`
4. Consider investigating root causes for index divergence
**Environment Check:**
- [ ] PUBLIC_URL is accessible
- [ ] ALGOLIA_* secrets are valid
- [ ] Database connection is working
- [ ] Search index is responsive
/cc @programmierbar/maintainers
`;
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['πŸ› bug', 'πŸ” search', 'πŸ€– automated']
});
- name: Comment on Success (Manual Run)
if: success() && github.event_name == 'workflow_dispatch'
env:
COLLECTION: ${{ github.event.inputs.collection || 'all' }}
run: |
echo "βœ… Algolia index repair completed successfully for collection: $COLLECTION"