Skip to content

try 2

try 2 #4

name: Knowledge Base CI/CD
on:
push:
branches: [ "main", "develop", "feature/*" ]
paths:
- 'knowledge-base/**'
- '.github/workflows/knowledge-base.yml'
pull_request:
branches: [ "main", "develop" ]
paths:
- 'knowledge-base/**'
- '.github/workflows/knowledge-base.yml'
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./knowledge-base
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
env:
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
PYTHONPATH: ${{ github.workspace }}/knowledge-base
run: |
pytest tests/ -v
docker:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./knowledge-base
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/knowledge-base:latest
${{ secrets.DOCKERHUB_USERNAME }}/knowledge-base:${{ github.sha }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/knowledge-base:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/knowledge-base:buildcache,mode=max