Skip to content

Commit

Permalink
remove duplicated vector index
Browse files Browse the repository at this point in the history
  • Loading branch information
Tadjaur committed Sep 9, 2024
1 parent 1a8ca1c commit 7f93e3b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
9 changes: 6 additions & 3 deletions .github/actions/setup-wrangler-toml/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: 'Generate Wrangler TOML'
description: 'Generates the wrangler.toml file for Cloudflare Workers'
inputs:
APP_URL:
description: 'The Application URL'
required: true
AWS_SIGN_ALGORITHM:
description: 'The AWS sign algorithm'
required: true
Expand Down Expand Up @@ -34,7 +37,7 @@ inputs:
STMP_EMAIL:
description: 'SMTP Email'
required: true
VECTOR_INDEX:
VECTOR_INDEX_NAME:
description: 'The vector index'
required: true
runs:
Expand All @@ -56,8 +59,9 @@ runs:
echo 'binding = "AI"' >> ${{ github.workspace }}/server/wrangler.toml
echo '[[env.${{ inputs.environment }}.vectorize]]' >> ${{ github.workspace }}/server/wrangler.toml
echo 'binding = "VECTOR_INDEX"' >> ${{ github.workspace }}/server/wrangler.toml
echo 'index_name = "vector-index-${{ inputs.environment }}"' >> ${{ github.workspace }}/server/wrangler.toml
echo 'index_name = "${{ inputs.VECTOR_INDEX_NAME }}"' >> ${{ github.workspace }}/server/wrangler.toml
echo '[env.${{ inputs.environment }}.vars]' >> ${{ github.workspace }}/server/wrangler.toml
echo 'APP_URL = "${{ inputs.APP_URL }}"' >> ${{ github.workspace }}/server/wrangler.toml
echo 'AWS_SIGN_ALGORITHM = "${{ inputs.AWS_SIGN_ALGORITHM }}"' >> ${{ github.workspace }}/server/wrangler.toml
echo 'BUCKET_ENDPOINT = "${{ inputs.BUCKET_ENDPOINT }}"' >> ${{ github.workspace }}/server/wrangler.toml
echo 'BUCKET_NAME = "${{ inputs.BUCKET_NAME }}"' >> ${{ github.workspace }}/server/wrangler.toml
Expand All @@ -69,5 +73,4 @@ runs:
echo 'NODE_ENV = "${{ inputs.environment }}"' >> ${{ github.workspace }}/server/wrangler.toml
echo 'OSM_URI = "https://overpass-api.de/api/interpreter"' >> ${{ github.workspace }}/server/wrangler.toml
echo 'STMP_EMAIL = "${{ inputs.STMP_EMAIL }}"' >> ${{ github.workspace }}/server/wrangler.toml
echo 'VECTOR_INDEX = "${{ inputs.VECTOR_INDEX }}"' >> ${{ github.workspace }}/server/wrangler.toml
echo 'WEATHER_URL = "https://api.openweathermap.org/data/2.5/forecast"' >> ${{ github.workspace }}/server/wrangler.toml
45 changes: 26 additions & 19 deletions .github/workflows/backend-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
uses: ./.github/actions/setup-wrangler-toml
with:
environment: preview
APP_URL: ${{ secrets.VITE_PUBLIC_APP_URL }}
AWS_SIGN_ALGORITHM: ${{ secrets.PREVIEW_AWS_SIGN_ALGORITHM }}
BUCKET_ENDPOINT: ${{ secrets.PREVIEW_BUCKET_ENDPOINT }}
BUCKET_NAME: ${{ secrets.PREVIEW_BUCKET_NAME }}
Expand All @@ -44,7 +45,7 @@ jobs:
DB_ID: ${{ secrets.PREVIEW_DB_ID }}
GOOGLE_CLIENT_ID: ${{ secrets.PREVIEW_GOOGLE_CLIENT_ID }}
STMP_EMAIL: ${{ secrets.PREVIEW_STMP_EMAIL }}
VECTOR_INDEX: ${{ secrets.PREVIEW_VECTOR_INDEX }}
VECTOR_INDEX_NAME: ${{ secrets.PREVIEW_VECTOR_INDEX }}

- name: Migrate database
uses: cloudflare/[email protected]
Expand All @@ -57,11 +58,6 @@ jobs:
echo '---Clear previous wrangler logs---'
rm /home/runner/.config/.wrangler/logs/* || true
command: d1 migrations apply preview --remote --env preview
postCommands: |
echo '\
---Print wrangler logs---\
'
cat "$(ls -t /home/runner/.config/.wrangler/logs/* | head -n 1)" || true;
packageManager: yarn
env:
NO_D1_WARNING: true
Expand All @@ -75,25 +71,36 @@ jobs:
cat "$(ls -t /home/runner/.config/.wrangler/logs/* | head -n 1)" || true;
- name: Deploy
if: always()
uses: cloudflare/[email protected]
with:
wranglerVersion: '3.75.0'
apiToken: skMQc0GKuojvn5rnaaAcabffiGTaypSKLnm-qVEs
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID}}
workingDirectory: server
preCommands: | # INFO: We need to upload secret manually because the default secrets input of this action `cloudflare/[email protected]` use the `wrangler secret put` command to upload secrets but this command will do not work non-interactive context.
echo '---Clear previous wrangler logs file---'
rm /home/runner/.config/.wrangler/logs/* || true
echo '---Generate and upload secrets---'
echo '>> Generate secrets file'
echo '{}' | jq '.WORKERS_AI_API_KEY="${{ secrets.PREVIEW_WORKERS_AI_API_KEY }}"|.VECTORIZE_API_KEY="${{ secrets.PREVIEW_VECTORIZE_API_KEY }}"|.BUCKET_ACCESS_KEY_ID="${{ secrets.PREVIEW_BUCKET_ACCESS_KEY_ID }}"|.GOOGLE_CLIENT_SECRET="${{ secrets.PREVIEW_GOOGLE_CLIENT_SECRET }}"|.JWT_SECRET="${{ secrets.PREVIEW_JWT_SECRET }}"|.MAPBOX_ACCESS_TOKEN="${{ secrets.PREVIEW_MAPBOX_ACCESS_TOKEN }}"|.OPENAI_API_KEY="${{ secrets.PREVIEW_OPENAI_API_KEY }}"|.OPENWEATHER_KEY="${{ secrets.PREVIEW_OPENWEATHER_KEY }}"|.SEND_GRID_API_KEY="${{ secrets.PREVIEW_SEND_GRID_API_KEY }}"|.STMP_PASSWORD="${{ secrets.PREVIEW_STMP_PASSWORD }}"|.VECTORIZE_API_KEY="${{ secrets.PREVIEW_VECTORIZE_API_KEY }}"|.X_AMZ_SECURITY_TOKEN="${{ secrets.PREVIEW_X_AMZ_SECURITY_TOKEN }}"|.JWT_VERIFICATION_KEY="${{ secrets.PREVIEW_JWT_SECRET }}"' > secrets.json
echo '<< Secrets file generated'
echo '>> Generated additional environment variables'
echo 'APP_URL=${{ secrets.VITE_PUBLIC_APP_URL }}' > .env.preview
echo '<< Additional environment variables generated'
echo '>> Upload secrets'
wrangler secret bulk --env preview secrets.json
# INFO: We need to upload secret manually because the default secrets input of this action `cloudflare/[email protected]` use the `wrangler secret put` command to upload secrets but this command will do not work non-interactive context.
preCommands: >
echo '---Clear previous wrangler logs file---' &&
rm /home/runner/.config/.wrangler/logs/* || true &&
echo '---Generate and upload secrets---' &&
echo '>> Generate secrets file' &&
echo '{}' | jq '
.WORKERS_AI_API_KEY="${{ secrets.PREVIEW_WORKERS_AI_API_KEY }}"|
.VECTORIZE_API_KEY="${{ secrets.PREVIEW_VECTORIZE_API_KEY }}"|
.BUCKET_ACCESS_KEY_ID="${{ secrets.PREVIEW_BUCKET_ACCESS_KEY_ID }}"|
.GOOGLE_CLIENT_SECRET="${{ secrets.PREVIEW_GOOGLE_CLIENT_SECRET }}"|
.JWT_SECRET="${{ secrets.PREVIEW_JWT_SECRET }}"|
.MAPBOX_ACCESS_TOKEN="${{ secrets.PREVIEW_MAPBOX_ACCESS_TOKEN }}"|
.OPENAI_API_KEY="${{ secrets.PREVIEW_OPENAI_API_KEY }}"|
.OPENWEATHER_KEY="${{ secrets.PREVIEW_OPENWEATHER_KEY }}"|
.SEND_GRID_API_KEY="${{ secrets.PREVIEW_SEND_GRID_API_KEY }}"|
.STMP_PASSWORD="${{ secrets.PREVIEW_STMP_PASSWORD }}"|
.VECTORIZE_API_KEY="${{ secrets.PREVIEW_VECTORIZE_API_KEY }}"|
.X_AMZ_SECURITY_TOKEN="${{ secrets.PREVIEW_X_AMZ_SECURITY_TOKEN }}"|
.JWT_VERIFICATION_KEY="${{ secrets.PREVIEW_JWT_SECRET }}"
' > secrets.json &&
echo '<< Secrets file generated' &&
echo '>> Upload secrets' &&
wrangler secret bulk --env preview secrets.json &&
echo '<< Secrets uploaded'
command: deploy src/index.ts --env preview
packageManager: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Backend Deployment'
name: 'Backend Production Deployment'

on:
workflow_dispatch:
Expand Down

0 comments on commit 7f93e3b

Please sign in to comment.