Skip to content

Update llama_index (#21) #112

Update llama_index (#21)

Update llama_index (#21) #112

name: Build and Deploy to Cloud Run
on:
push:
branches:
- main
paths-ignore:
- "jupyter/**"
- "ui/**"
pull_request:
branches:
- main
paths-ignore:
- "jupyter/**"
- "ui/**"
env:
GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }}
APPLICATION_NAME: knowledge-chatbot
GCLOUD_IMAGE_REPOSITORY: knowledge-chatbot
GCLOUD_REGION: europe-west3
GCLOUD_GCR: eu.gcr.io
GCLOUD_PKG_LOCATION: europe-west3-docker.pkg.dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ hashFiles('requirements.txt') }}
- name: Run tests
run: |
python -m pip install --upgrade pip
pip install ruff pytest
if [ -f requirements-all.txt ]; then pip install -r requirements-all.txt; fi
pytest --junitxml=test_results.xml
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- id: "auth"
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCLOUD_SA_KEY }}"
- name: Setup Google Cloud CLI
if: ${{ (github.ref == 'refs/heads/main') || (startsWith(github.ref, 'refs/tags/')) }}
uses: google-github-actions/setup-gcloud@v2
with:
version: "latest"
- name: Docker Login
run: |
gcloud auth configure-docker europe-west3-docker.pkg.dev
- name: Build And Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ (github.ref == 'refs/heads/main') || (startsWith(github.ref, 'refs/tags/')) }}
tags: ${{ env.GCLOUD_PKG_LOCATION }}/${{ env.GCLOUD_PROJECT_ID }}/${{ env.GCLOUD_IMAGE_REPOSITORY }}/${{ env.APPLICATION_NAME }}:${{ github.sha }}
cache-from: type=registry,ref=${{ env.GCLOUD_PKG_LOCATION }}/${{ env.GCLOUD_PROJECT_ID }}/${{ env.GCLOUD_IMAGE_REPOSITORY }}/${{ env.APPLICATION_NAME }}:${{ github.sha }}
cache-to: type=inline
- name: Deploy Cloud Run
if: ${{ (github.ref == 'refs/heads/main') || (startsWith(github.ref, 'refs/tags/')) }}
run: |
export DOCKER_IMAGE="${{ env.GCLOUD_PKG_LOCATION }}/${{ env.GCLOUD_PROJECT_ID }}/${{ env.GCLOUD_IMAGE_REPOSITORY }}/${{ env.APPLICATION_NAME }}:${{ github.sha }}"
gcloud run deploy ${APPLICATION_NAME} --quiet \
--image "${DOCKER_IMAGE}" --project "${GCLOUD_PROJECT_ID}" \
--memory "1Gi" \
--region "${GCLOUD_REGION}" \
--set-env-vars "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" \
--platform managed \
--allow-unauthenticated \
--format json
echo "Invoke endpoint:"
gcloud run services list --platform managed --format json | jq -r \
'.[] | select(.metadata.name == "google-cloud-run-maven-test") | .status.address.url'
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: "Pytest"
files: |
test_results.xml