name: Github-Docker Hub MLOps pipeline - RAG Catastrophes Climatiques env: DOCKER_USER: ${{secrets.DOCKER_USER}} DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} REPO_NAME: ${{secrets.REPO_NAME}} on: push: branches: - main pull_request: branches: - main jobs: ci_pipeline: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python 3.11 uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Format run: | black --check src/ app.py tests/ - name: Lint run: | pylint --exit-zero --disable=R,C,W0603,W0718,W0621,W0123,W0612,W0613,W0221,W0212,E1102,E0401,E0611,E1101 src/ app.py - name: Test run: | python -m pytest -vv tests/ cd_pipeline: runs-on: ubuntu-latest needs: [ci_pipeline] if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 - name: Docker Hub login uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Set up Python 3.11 uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install dependencies for training run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Train ML models (regenerate joblib artifacts) run: | python scripts/train_nb10.py - name: Verify artifacts were created run: | ls -la outputs/NB10_*.joblib ls -la outputs/NB10_predictions_2030_*.csv - name: Get current date id: date run: echo "date=$(date +'%Y-%m-%d--%H-%M-%S')" >> $GITHUB_OUTPUT - name: Build the Docker image (tag date + latest) run: | docker build --no-cache . --file Dockerfile \ --tag $DOCKER_USER/$REPO_NAME:${{ steps.date.outputs.date }} \ --tag $DOCKER_USER/$REPO_NAME:latest - name: Docker Push (both tags) run: | docker push $DOCKER_USER/$REPO_NAME:${{ steps.date.outputs.date }} docker push $DOCKER_USER/$REPO_NAME:latest