|
| 1 | +name: Main deployment of Chatbot lambda function |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + name: Staging deployment tests |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + python-version: ["3.13"] |
| 16 | + env: |
| 17 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 18 | + OPENAI_MODEL: ${{ vars.OPENAI_MODEL }} |
| 19 | + GOOGLE_AI_API_KEY: ${{ secrets.GOOGLE_AI_API_KEY }} |
| 20 | + GOOGLE_AI_MODEL: ${{ vars.GOOGLE_AI_MODEL }} |
| 21 | + steps: |
| 22 | + - name: Checkout Code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Set up Python ${{ matrix.python-version }} |
| 26 | + id: python-setup |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: ${{ matrix.python-version }} |
| 30 | + |
| 31 | + # - name: Load cached venv |
| 32 | + # id: dependencies-cache |
| 33 | + # uses: actions/cache@v3 |
| 34 | + # with: |
| 35 | + # path: .venv |
| 36 | + # key: venv-${{ runner.os }}-${{ steps.python-setup.outputs.python-version }} |
| 37 | + |
| 38 | + - name: Create Venv if Cache not found |
| 39 | + # if: steps.dependencies-cache.outputs.cache-hit != 'true' |
| 40 | + run: | |
| 41 | + python -m venv .venv |
| 42 | +
|
| 43 | + - name: Install dependencies |
| 44 | + # if: steps.dependencies-cache.outputs.cache-hit != 'true' |
| 45 | + run: | |
| 46 | + pip install --upgrade pip |
| 47 | + pip install -r requirements.txt |
| 48 | +
|
| 49 | + - name: Run tests |
| 50 | + if: always() |
| 51 | + run: | |
| 52 | + source .venv/bin/activate |
| 53 | + pytest --junit-xml=./reports/pytest.xml --tb=auto -v |
| 54 | +
|
| 55 | + - name: Upload test results |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + if: always() |
| 58 | + with: |
| 59 | + name: test-results |
| 60 | + path: ./reports/pytest.xml |
| 61 | + if-no-files-found: warn |
| 62 | + |
| 63 | + build: |
| 64 | + name: Build Docker Image |
| 65 | + uses: lambda-feedback/chat-function-workflows/.github/workflows/gh_build.yml@main |
| 66 | + needs: test |
| 67 | + permissions: |
| 68 | + contents: read |
| 69 | + id-token: write |
| 70 | + packages: write |
| 71 | + |
| 72 | + deploy: |
| 73 | + name: Deploy to Lambda Feedback |
| 74 | + uses: lambda-feedback/chat-function-workflows/.github/workflows/main_deploy.yml@main |
| 75 | + needs: test |
| 76 | + with: |
| 77 | + template-repository-name: "lambda-feedback/chat-function-boilerplate" |
| 78 | + # allow for developer to specify the environment variables that are used by the deployed AWS Lambda. Default to mock then admin can update. |
| 79 | + deployed-environment-variables: '[\"OPENAI_API_KEY\",\"OPENAI_MODEL\",\"GOOGLE_AI_API_KEY\",\"GOOGLE_AI_MODEL\"]' |
| 80 | + permissions: |
| 81 | + contents: read |
| 82 | + id-token: write |
| 83 | + packages: write |
| 84 | + issues: write |
| 85 | + secrets: |
| 86 | + aws-access-key-id: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_ID }} |
| 87 | + aws-secret-key: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_SECRET}} |
| 88 | + function-admin-api-key: ${{ secrets.FUNCTION_ADMIN_API_KEY }} |
| 89 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments