fix: ci-cd pipeline004 #5
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: CD - Build and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| container: docker://ghcr.io/iterative/cml:0-dvc2-base1 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Install Python CI dependencies | |
| - name: Install CI requirements | |
| run: | | |
| pip install --upgrade pip | |
| pip install -r requirements-ci.txt | |
| # Authenticate to Google Cloud | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| # Configure Docker for Artifact Registry | |
| - name: Configure Docker for Artifact Registry | |
| run: | | |
| gcloud auth configure-docker --quiet us-central1-docker.pkg.dev | |
| # Build Docker image | |
| - name: Build Docker image | |
| run: | | |
| docker build -t us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/fraud-api/fraud-detection-api:${{ github.sha }} . | |
| # Push Docker image | |
| - name: Push Docker image | |
| run: | | |
| docker push us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/fraud-api/fraud-detection-api:${{ github.sha }} | |
| # Post CML report | |
| - name: CML Report | |
| env: | |
| REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "## 🚀 Docker Image Built & Pushed" > report.md | |
| echo "- Image tag: ${{ github.sha }}" >> report.md | |
| cml comment create report.md |