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: MachineLearning Continuous Integartion & Delivery PipeLine | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
| DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
| GIT_USERNAME: ${{ secrets.GIT_USERNAME }} | |
| GIT_EMAIL: ${{ secrets.GIT_EMAIL }} | |
| jobs: | |
| Setup: | |
| name: Setup Environment for CI/CD | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| build : | |
| name: Continuous Integration and Delivery | |
| runs-on: ubuntu-latest | |
| env: | |
| DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
| DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
| steps: | |
| - name: checkout code | |
| uses: actions/checkout@v4 | |
| - name: set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
| - name: Build image | |
| run: docker build -t $DOCKER_USERNAME/myapp:latest . | |
| - name: Scan Docker image with Trivy | |
| run: | | |
| docker run --rm \ | |
| -v /var/run/docker.sock:/var/run/docker.sock \ | |
| aquasec/trivy:latest image $DOCKER_USERNAME/myapp:latest || true | |
| - name: Push image to Docker Hub | |
| run: docker push $DOCKER_USERNAME/myapp:latest | |