From 2315c833b4b5a7df00815c0ad643492f1652faa5 Mon Sep 17 00:00:00 2001 From: Diego Marvid Date: Fri, 5 Jul 2024 14:49:09 -0300 Subject: [PATCH] add cd workflow --- .github/workflows/cd.yml | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..8b85566 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,65 @@ +name: 'Continuous Delivery' + +on: + push: + branches: + - develop + - release/* + pull_request: + branches: + - develop + - release/* + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + make install + + - name: Set up Google Cloud SDK + uses: google-github-actions/auth@v1 + with: + credentials_json: ${{ secrets.GCP_CREDENTIALS }} + + - name: Configure Docker + run: gcloud auth configure-docker + + - name: Setup gcloud CLI + uses: google-github-actions/setup-gcloud@v1 + with: + version: '390.0.0' + service_account_key: ${{ secrets.GCP_CREDENTIALS }} + + - name: Download Model from GCS + run: gsutil cp gs://diego-tryolabs-latam_cloudbuild/${{ secrets.MODEL_NAME }}.json model.json + + - name: Submit Build + run: gcloud builds submit --region ${{ secrets.GCP_REGION }} --tag ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/delay-model/${{ secrets.GCP_IMAGE_NAME }}:latest + + - name: Deploy to Cloud Run + run: gcloud run deploy ${{ secrets.GCP_IMAGE_NAME }} --image ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/delay-model/${{ secrets.GCP_IMAGE_NAME }}:latest --allow-unauthenticated --region ${{ secrets.GCP_REGION }} + + - name: Run Stress Test + run: make stress-test + + \ No newline at end of file