From f8d2e47e24df875eabf2c9df0003bd4dd241c1c0 Mon Sep 17 00:00:00 2001 From: Aditya Banerjee Date: Tue, 6 Feb 2024 23:53:58 +0800 Subject: [PATCH] update workflows and search query params --- .github/workflows/deploy-database.yml | 66 ++++++ .github/workflows/deploy.yml | 308 +++++++++++--------------- telegram-bot/src/components/bot.ts | 2 +- 3 files changed, 191 insertions(+), 185 deletions(-) create mode 100644 .github/workflows/deploy-database.yml diff --git a/.github/workflows/deploy-database.yml b/.github/workflows/deploy-database.yml new file mode 100644 index 0000000..2152279 --- /dev/null +++ b/.github/workflows/deploy-database.yml @@ -0,0 +1,66 @@ +name: Deploy database to Heroku + +on: + push: + branches: + - deploy-database + +jobs: + deploy-database: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Heroku CLI + run: | + curl https://cli-assets.heroku.com/install.sh | sh + + - name: Login to Heroku container registry + run: heroku container:login + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Check if Heroku app exists + id: check_app + run: | + if heroku apps:info echofinder-database > /dev/null 2>&1; then + echo "App exists" + echo "::set-output name=exists::true" + else + echo "App does not exist" + echo "::set-output name=exists::false" + fi + env: + HEROKU_APP_NAME: echofinder-database + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Create Heroku app + if: steps.check_app.outputs.exists == 'false' + run: heroku create echofinder-database + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Build Docker image + run: cd database && docker build -t registry.heroku.com/echofinder-database/web . + + - name: Push Docker image to Heroku container registry + run: cd database && docker push registry.heroku.com/echofinder-database/web + + - name: Set environment variables + run: | + cd database && heroku config:set \ + CHROMA_SERVER_AUTH_CREDENTIALS=${{ secrets.CHROMA_SERVER_AUTH_CREDENTIALS }} \ + CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER=${{ secrets.CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER }} \ + CHROMA_SERVER_AUTH_PROVIDER=${{ secrets.CHROMA_SERVER_AUTH_PROVIDER }} \ + CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER=${{ secrets.CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER }} \ + PERSIST_DIRECTORY=${{ secrets.PERSIST_DIRECTORY }} \ + --app echofinder-database + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Release Docker image to Heroku + run: cd database && heroku container:release web --app echofinder-database + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ba4af42..8343b22 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,189 +1,129 @@ name: Deploy to Heroku on: - push: - branches: - - main + push: + branches: + - main jobs: - deploy-database: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install Heroku CLI - run: | - curl https://cli-assets.heroku.com/install.sh | sh - - - name: Login to Heroku container registry - run: heroku container:login - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Check if Heroku app exists - id: check_app - run: | - if heroku apps:info echofinder-database > /dev/null 2>&1; then - echo "App exists" - echo "::set-output name=exists::true" - else - echo "App does not exist" - echo "::set-output name=exists::false" - fi - env: - HEROKU_APP_NAME: echofinder-database - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Create Heroku app - if: steps.check_app.outputs.exists == 'false' - run: heroku create echofinder-database - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Build Docker image - run: cd database && docker build -t registry.heroku.com/echofinder-database/web . - - - name: Push Docker image to Heroku container registry - run: cd database && docker push registry.heroku.com/echofinder-database/web - - - name: Set environment variables - run: | - cd database && heroku config:set \ - CHROMA_SERVER_AUTH_CREDENTIALS=${{ secrets.CHROMA_SERVER_AUTH_CREDENTIALS }} \ - CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER=${{ secrets.CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER }} \ - CHROMA_SERVER_AUTH_PROVIDER=${{ secrets.CHROMA_SERVER_AUTH_PROVIDER }} \ - CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER=${{ secrets.CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER }} \ - PERSIST_DIRECTORY=${{ secrets.PERSIST_DIRECTORY }} \ - --app echofinder-database - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Release Docker image to Heroku - run: cd database && heroku container:release web --app echofinder-database - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - deploy-backend: - needs: deploy-database - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install Heroku CLI - run: | - curl https://cli-assets.heroku.com/install.sh | sh - - - name: Login to Heroku container registry - run: heroku container:login - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Check if Heroku app exists - id: check_app - run: | - if heroku apps:info echofinder-backend > /dev/null 2>&1; then - echo "App exists" - echo "::set-output name=exists::true" - else - echo "App does not exist" - echo "::set-output name=exists::false" - fi - env: - HEROKU_APP_NAME: echofinder-backend - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Create Heroku app - if: steps.check_app.outputs.exists == 'false' - run: heroku create echofinder-backend - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Build Docker image - run: cd backend && docker build -t registry.heroku.com/echofinder-backend/web . - - - name: Push Docker image to Heroku container registry - run: cd backend && docker push registry.heroku.com/echofinder-backend/web - - - name: Set environment variables - run: | - cd backend && heroku config:set \ - CHROMA_HOST=${{ secrets.CHROMA_HOST }} \ - CHROMA_PORT=${{ secrets.CHROMA_PORT }} \ - API_KEY=${{ secrets.BACKEND_API_KEY }} \ - CHROMA_API_KEY=${{ secrets.CHROMA_SERVER_AUTH_CREDENTIALS }} \ - --app echofinder-backend - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Release Docker image to Heroku - run: cd backend && heroku container:release web --app echofinder-backend - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - deploy-telegram-bot: - needs: deploy-backend - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install Heroku CLI - run: | - curl https://cli-assets.heroku.com/install-ubuntu.sh | sh - - - name: Login to Heroku Container Registry - run: heroku container:login - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Check if Heroku app exists - id: check_app - run: | - if heroku apps:info echofinder-telegram > /dev/null 2>&1; then - echo "App exists" - echo "::set-output name=exists::true" - else - echo "App does not exist" - echo "::set-output name=exists::false" - fi - env: - HEROKU_APP_NAME: echofinder-telegram - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Create Heroku app - if: steps.check_app.outputs.exists == 'false' - run: heroku apps:create echofinder-telegram - env: - HEROKU_APP_NAME: echofinder-telegram - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Build Docker image - run: cd telegram-bot && docker build -t registry.heroku.com/echofinder-telegram/web . - - - name: Push Docker image to Heroku Container Registry - run: cd telegram-bot && docker push registry.heroku.com/echofinder-telegram/web - - - name: Set environment variables - run: | - cd telegram-bot && heroku config:set \ - TELEGRAM_BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }} \ - TELEGRAM_BOT_WEBHOOK_URL=${{ secrets.TELEGRAM_BOT_WEBHOOK_URL }} \ - NODE_ENV=${{ secrets.NODE_ENV }} \ - BACKEND_HOST=${{ secrets.BACKEND_HOST }} \ - BACKEND_PORT=${{ secrets.BACKEND_PORT }} \ - BACKEND_API_KEY=${{ secrets.BACKEND_API_KEY }} \ - API_CLIENT_TIMEOUT=${{ secrets.API_CLIENT_TIMEOUT }} \ - PLATFORM=${{ secrets.PLATFORM }} \ - --app echofinder-telegram - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} - - - name: Release Docker image on Heroku - run: cd telegram-bot && heroku container:release web --app echofinder-telegram - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + deploy-backend: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Heroku CLI + run: | + curl https://cli-assets.heroku.com/install.sh | sh + + - name: Login to Heroku container registry + run: heroku container:login + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Check if Heroku app exists + id: check_app + run: | + if heroku apps:info echofinder-backend > /dev/null 2>&1; then + echo "App exists" + echo "::set-output name=exists::true" + else + echo "App does not exist" + echo "::set-output name=exists::false" + fi + env: + HEROKU_APP_NAME: echofinder-backend + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Create Heroku app + if: steps.check_app.outputs.exists == 'false' + run: heroku create echofinder-backend + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Build Docker image + run: cd backend && docker build -t registry.heroku.com/echofinder-backend/web . + + - name: Push Docker image to Heroku container registry + run: cd backend && docker push registry.heroku.com/echofinder-backend/web + + - name: Set environment variables + run: | + cd backend && heroku config:set \ + CHROMA_HOST=${{ secrets.CHROMA_HOST }} \ + CHROMA_PORT=${{ secrets.CHROMA_PORT }} \ + API_KEY=${{ secrets.BACKEND_API_KEY }} \ + CHROMA_API_KEY=${{ secrets.CHROMA_SERVER_AUTH_CREDENTIALS }} \ + --app echofinder-backend + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Release Docker image to Heroku + run: cd backend && heroku container:release web --app echofinder-backend + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + deploy-telegram-bot: + needs: deploy-backend + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Heroku CLI + run: | + curl https://cli-assets.heroku.com/install-ubuntu.sh | sh + + - name: Login to Heroku Container Registry + run: heroku container:login + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Check if Heroku app exists + id: check_app + run: | + if heroku apps:info echofinder-telegram > /dev/null 2>&1; then + echo "App exists" + echo "::set-output name=exists::true" + else + echo "App does not exist" + echo "::set-output name=exists::false" + fi + env: + HEROKU_APP_NAME: echofinder-telegram + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Create Heroku app + if: steps.check_app.outputs.exists == 'false' + run: heroku apps:create echofinder-telegram + env: + HEROKU_APP_NAME: echofinder-telegram + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Build Docker image + run: cd telegram-bot && docker build -t registry.heroku.com/echofinder-telegram/web . + + - name: Push Docker image to Heroku Container Registry + run: cd telegram-bot && docker push registry.heroku.com/echofinder-telegram/web + + - name: Set environment variables + run: | + cd telegram-bot && heroku config:set \ + TELEGRAM_BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }} \ + TELEGRAM_BOT_WEBHOOK_URL=${{ secrets.TELEGRAM_BOT_WEBHOOK_URL }} \ + NODE_ENV=${{ secrets.NODE_ENV }} \ + BACKEND_HOST=${{ secrets.BACKEND_HOST }} \ + BACKEND_PORT=${{ secrets.BACKEND_PORT }} \ + BACKEND_API_KEY=${{ secrets.BACKEND_API_KEY }} \ + API_CLIENT_TIMEOUT=${{ secrets.API_CLIENT_TIMEOUT }} \ + PLATFORM=${{ secrets.PLATFORM }} \ + --app echofinder-telegram + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + + - name: Release Docker image on Heroku + run: cd telegram-bot && heroku container:release web --app echofinder-telegram + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} diff --git a/telegram-bot/src/components/bot.ts b/telegram-bot/src/components/bot.ts index 876dfcd..fd6c6bc 100644 --- a/telegram-bot/src/components/bot.ts +++ b/telegram-bot/src/components/bot.ts @@ -136,9 +136,9 @@ export class Bot { this.getMessageMetadata(message); try { const query = message_content.replace(regex, '').trim(); - console.log('query', query); const response = await this.apiClient.get('/messages/search', { search_string: query, + chat_id, }); const data = response; const { documents } = data;