Skip to content

Search Index Update #150

Search Index Update

Search Index Update #150

Workflow file for this run

name: Search Index Update
on:
workflow_run:
workflows:
- Deploy Production
types:
- completed
permissions: {}
concurrency:
group: search-index-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: false
jobs:
upstash-search-index:
name: Upstash Search Index
runs-on: ubuntu-latest
environment: production
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main'
permissions:
actions: read
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- name: Install Python dependencies
run: python3 -m pip install -r requirements.txt
- name: Determine sections to crawl
id: scope
uses: ./.github/actions/determine-search-index-scope
with:
token: ${{ github.token }}
workflow_file: deployment-production.yml
base_branch: main
current_run_id: ${{ github.event.workflow_run.id }}
head_sha: ${{ github.event.workflow_run.head_sha }}
- name: Validate Upstash credentials
if: steps.scope.outputs.should_index == 'true'
run: |
if [ -z "${{ vars.UPSTASH_SEARCH_REST_URL }}" ]; then
echo "Missing UPSTASH_SEARCH_REST_URL variable" >&2
exit 1
fi
if [ -z "${{ secrets.UPSTASH_SEARCH_REST_TOKEN }}" ]; then
echo "Missing UPSTASH_SEARCH_REST_TOKEN secret" >&2
exit 1
fi
- name: Index changed collections
if: steps.scope.outputs.should_index == 'true'
env:
UPSTASH_SEARCH_REST_URL: ${{ vars.UPSTASH_SEARCH_REST_URL }}
UPSTASH_SEARCH_REST_TOKEN: ${{ secrets.UPSTASH_SEARCH_REST_TOKEN }}
run: |
COLLECTIONS=""
if [ "${{ steps.scope.outputs.crawl_articles }}" = "true" ]; then
COLLECTIONS="$COLLECTIONS --collection articles"
fi
if [ "${{ steps.scope.outputs.crawl_services }}" = "true" ]; then
COLLECTIONS="$COLLECTIONS --collection services"
fi
if [ "${{ steps.scope.outputs.crawl_case_studies }}" = "true" ]; then
COLLECTIONS="$COLLECTIONS --collection case-studies"
fi
python3 scripts/search-index.py --no-drop $COLLECTIONS
- name: Prune removed /articles
if: steps.scope.outputs.should_index == 'true' && steps.scope.outputs.crawl_articles == 'true'
uses: ./.github/actions/prune-upstash-search
with:
github_token: ${{ github.token }}
workflow_file: deployment-production.yml
base_branch: main
current_run_id: ${{ github.event.workflow_run.id }}
head_sha: ${{ github.event.workflow_run.head_sha }}
upstash_url: ${{ vars.UPSTASH_SEARCH_REST_URL }}
upstash_token: ${{ secrets.UPSTASH_SEARCH_REST_TOKEN }}
index_name: default
site_origin: https://www.webstackbuilders.com
collection: articles
- name: Prune removed /services
if: steps.scope.outputs.should_index == 'true' && steps.scope.outputs.crawl_services == 'true'
uses: ./.github/actions/prune-upstash-search
with:
github_token: ${{ github.token }}
workflow_file: deployment-production.yml
base_branch: main
current_run_id: ${{ github.event.workflow_run.id }}
head_sha: ${{ github.event.workflow_run.head_sha }}
upstash_url: ${{ vars.UPSTASH_SEARCH_REST_URL }}
upstash_token: ${{ secrets.UPSTASH_SEARCH_REST_TOKEN }}
index_name: default
site_origin: https://www.webstackbuilders.com
collection: services
- name: Prune removed /case-studies
if: steps.scope.outputs.should_index == 'true' && steps.scope.outputs.crawl_case_studies == 'true'
uses: ./.github/actions/prune-upstash-search
with:
github_token: ${{ github.token }}
workflow_file: deployment-production.yml
base_branch: main
current_run_id: ${{ github.event.workflow_run.id }}
head_sha: ${{ github.event.workflow_run.head_sha }}
upstash_url: ${{ vars.UPSTASH_SEARCH_REST_URL }}
upstash_token: ${{ secrets.UPSTASH_SEARCH_REST_TOKEN }}
index_name: default
site_origin: https://www.webstackbuilders.com
collection: case-studies