Added github CI/CD. Needs to be tested
This commit is contained in:
parent
31c2a49304
commit
86cbd29818
2 changed files with 51 additions and 32 deletions
51
.github/workflows/ci-cd.yml
vendored
Normal file
51
.github/workflows/ci-cd.yml
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
name: CI/CD Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r deployment/api/requirements.txt
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
pytest tests/ # adapte le chemin à ton dossier de tests
|
||||
|
||||
build_and_push:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
if: success()
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ./deployment/api
|
||||
file: ./deployment/api/Dockerfile
|
||||
push: true
|
||||
tags: yourdockerhubusername/sentiment_api:latest
|
||||
32
.github/workflows/workflow.yml
vendored
32
.github/workflows/workflow.yml
vendored
|
|
@ -1,32 +0,0 @@
|
|||
name: Build and Deploy API
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build-and-run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ./deployment/api
|
||||
push: false
|
||||
tags: sentiment_api:latest
|
||||
|
||||
- name: Run docker-compose
|
||||
run: docker-compose up -d
|
||||
Loading…
Add table
Reference in a new issue