Added GitHub Actions CI/CD pipeline for test, Docker build, and ECR d… #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "pip" | |
| cache-dependency-path: docker_image/requirements.txt | |
| - name: Install dependencies | |
| run: | | |
| pip install -r docker_image/requirements.txt | |
| pip install pytest httpx | |
| - name: Run tests | |
| working-directory: docker_image/src | |
| run: pytest ../../tests/ -v | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build Docker image | |
| run: docker build -t rag-app docker_image/ | |
| deploy: | |
| needs: [test, docker-build] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Build and push Docker image | |
| run: | | |
| docker build -t rag-app docker_image/ | |
| docker tag rag-app:latest ${{ secrets.ECR_REPOSITORY_URI }}:latest | |
| docker push ${{ secrets.ECR_REPOSITORY_URI }}:latest |