Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions .github/actions/chatbot/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,12 @@ runs:
- name: Install python libraries
shell: bash
run: |
cd apps/chatbot
cd apps/chatbot-index
poetry config virtualenvs.create false
poetry install --only main --no-interaction

# - name: Run tests
# run: |
# cd apps/chatbot
# poetry run pytest
# coverage report
#

- name: Create Vector Index
shell: bash
run: |
cd apps/chatbot
PYTHONPATH=. poetry run python src/modules/create_vector_index.py --params config/params.yaml

- name: Restart backend lambda function
env:
CHATBOT_LAMBDA_NAME: ${{ inputs.chatbot_lambda_name }}
shell: bash
run: |
aws lambda update-function-code --function-name "${{ env.CHATBOT_LAMBDA_NAME }}" --image-uri $(aws lambda get-function --function-name "${{ env.CHATBOT_LAMBDA_NAME }}" --query 'Code.ImageUri' --output text)
cd apps/chatbot-index
PYTHONPATH=. poetry run python src/modules/create_vector_index.py
83 changes: 83 additions & 0 deletions .github/workflows/chatbot_create_index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
name: Chatbot Create Index

on:
workflow_dispatch:
inputs:
environment:
description: 'The environment used as target'
type: choice
required: true
default: dev
options:
- dev
- uat
- prod

# Allows external webhook trigger
repository_dispatch:
types:
- webhook

# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

jobs:

cd_create_index:
name: Llama create index (cd_create_index on ${{ matrix.environment }})
# Trigger on a webhook (e.g. trigger create index from CMS)
if: github.event_name == 'repository_dispatch'
runs-on: codebuild-${{ matrix.environment }}-github-runner-${{ github.run_id }}-${{ github.run_attempt }}
strategy:
matrix:
environment: [ 'dev', 'uat', 'prod' ]
fail-fast: false

environment: ${{ matrix.environment }}

concurrency:
group: ${{ github.workflow }}-${{ matrix.environment }}
cancel-in-progress: false

steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
role-to-assume: ${{ secrets.IAM_ROLE_CHATBOT_REINDEX }}
aws-region: eu-south-1

- name: Chatbot Vector Index
uses: ./.github/actions/chatbot
with:
chatbot_lambda_name: ${{ vars.CHATBOT_LAMBDA_NAME }}

manual_create_index:
name: Llama create index (manual on ${{ inputs.environment }})
if: github.event_name == 'workflow_dispatch'
runs-on: codebuild-${{ inputs.environment }}-github-runner-${{ github.run_id }}-${{ github.run_attempt }}
environment: ${{ inputs.environment }}

concurrency:
group: ${{ github.workflow }}-${{ inputs.environment }}
cancel-in-progress: false

steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
role-to-assume: ${{ secrets.IAM_ROLE_CHATBOT_REINDEX }}
aws-region: eu-south-1

- name: Chatbot Vector Index
uses: ./.github/actions/chatbot
with:
chatbot_lambda_name: ${{ vars.CHATBOT_LAMBDA_NAME }}