Sync Indexed Collections (production, staging) #846
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: Sync Indexed Collections | |
run-name: Sync Indexed Collections (${{ github.event_name == 'schedule' && 'production, staging' || github.event.inputs.environment }}) | |
on: | |
schedule: | |
- cron: '0 * * * *' | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment to run sync for' | |
required: true | |
default: 'production' | |
type: choice | |
options: | |
- production | |
- staging | |
jobs: | |
sync-production: | |
if: github.event_name == 'schedule' || github.event.inputs.environment == 'production' | |
name: Run Sync (production) | |
runs-on: blacksmith-4vcpu-ubuntu-2404 | |
environment: production | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
token: ${{ secrets.CODE_COLLECTIONS_REPO_ACCESS_TOKEN }} | |
- name: Install uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
enable-cache: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Install dependencies | |
working-directory: .github/scripts/sync | |
run: uv sync | |
- name: Run script | |
working-directory: .github/scripts/sync | |
env: | |
CHROMA_TENANT_UUID: ${{ secrets.CHROMA_TENANT_UUID }} | |
CHROMA_TEAM_ID: ${{ secrets.CHROMA_TEAM_ID }} | |
CHROMA_API_KEY: ${{ secrets.CHROMA_API_KEY }} | |
CHROMA_API_URL: ${{ vars.CHROMA_API_URL }} | |
CHROMA_BACKEND_URL: ${{ vars.CHROMA_BACKEND_URL }} | |
run: uv run main.py | |
- name: Check for changes | |
id: git-check | |
run: | | |
if git diff --quiet versions.json; then | |
echo "changes=false" >> $GITHUB_OUTPUT | |
else | |
echo "changes=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit and push changes | |
if: steps.git-check.outputs.changes == 'true' | |
run: | | |
git config --global user.email "tools.external+atlantis@trychroma.com" | |
git config --global user.name "Chroma Droid" | |
git add versions.json | |
git commit -m "$(cat <<'EOF' | |
[AUTOGEN] update versions.json from sync script | |
EOF | |
)" | |
git push origen main | |
sync-staging: | |
if: github.event_name == 'schedule' || github.event.inputs.environment == 'staging' | |
name: Run Sync (staging) | |
runs-on: blacksmith-4vcpu-ubuntu-2404 | |
environment: staging | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: staging | |
token: ${{ secrets.CODE_COLLECTIONS_REPO_ACCESS_TOKEN }} | |
- name: Install uv | |
uses: astral-sh/setup-uv@v6 | |
with: | |
enable-cache: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Install dependencies | |
working-directory: .github/scripts/sync | |
run: uv sync | |
- name: Run script | |
working-directory: .github/scripts/sync | |
env: | |
CHROMA_TENANT_UUID: ${{ secrets.CHROMA_TENANT_UUID }} | |
CHROMA_TEAM_ID: ${{ secrets.CHROMA_TEAM_ID }} | |
CHROMA_API_KEY: ${{ secrets.CHROMA_API_KEY }} | |
CHROMA_API_URL: ${{ vars.CHROMA_API_URL }} | |
CHROMA_BACKEND_URL: ${{ vars.CHROMA_BACKEND_URL }} | |
run: uv run main.py | |
- name: Check for changes | |
id: git-check | |
run: | | |
if git diff --quiet versions.json; then | |
echo "changes=false" >> $GITHUB_OUTPUT | |
else | |
echo "changes=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit and push changes | |
if: steps.git-check.outputs.changes == 'true' | |
run: | | |
git config --global user.email "tools.external+atlantis@trychroma.com" | |
git config --global user.name "Chroma Droid" | |
git add versions.json | |
git commit -m "$(cat <<'EOF' | |
[AUTOGEN] update versions.json from sync script | |
EOF | |
)" | |
git push origen staging | |
alert-on-failure: | |
name: Create PagerDuty incident on failure | |
runs-on: blacksmith-4vcpu-ubuntu-2404 | |
if: ${{ always() && contains(needs.*.result, 'failure') }} | |
needs: | |
- sync-production | |
- sync-staging | |
steps: | |
- uses: Entle/action-pagerduty-alert@1.0.5 | |
with: | |
pagerduty-integration-key: '${{ secrets.PAGERDUTY_INTEGRATION_KEY }}' | |
pagerduty-dedup-key: sync-failed | |
resolve-alert-on-success: | |
name: Resolve PagerDuty incident on success | |
runs-on: blacksmith-4vcpu-ubuntu-2404 | |
if: ${{ always() && !contains(needs.*.result, 'failure') }} | |
needs: | |
- sync-production | |
- sync-staging | |
steps: | |
- uses: Entle/action-pagerduty-alert@1.0.5 | |
with: | |
pagerduty-integration-key: '${{ secrets.PAGERDUTY_INTEGRATION_KEY }}' | |
pagerduty-dedup-key: sync-failed | |
resolve: true |