From 371e289b4ee723c91295fbb6ab65c1b5c6a25423 Mon Sep 17 00:00:00 2001 From: dewisnu Date: Sun, 17 Dec 2023 15:42:07 +0800 Subject: [PATCH] feat: add ci cd work flow --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b13789..7f50ee6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1 +1,37 @@ +name: Deploy API ML Brait +on: + push: + branches: + - 'main' +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: code checkout + uses: actions/checkout@v2 + + - name: install the gcloud cli + uses: google-github-actions/setup-gcloud@v0 + with: + project_id: ${{ secrets.GOOGLE_PROJECT }} + service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + export_default_credentials: true + + - name: build and push the docker image + env: + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + run: | + gcloud auth configure-docker asia-southeast2-docker.pkg.dev + docker build --platform linux/amd64 -t asia-southeast2-docker.pkg.dev/$GOOGLE_PROJECT/ci-cd-pipeline/BRAIT-machine-learning-API:latest . + docker push asia-southeast2-docker.pkg.dev/$GOOGLE_PROJECT/ci-cd-pipeline/BRAIT-machine-learning-API:latest + - name: deploy to Cloud Run + env: + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + run: | + gcloud run deploy back-end-service-brait \ + --image asia-southeast2-docker.pkg.dev/$GOOGLE_PROJECT/ci-cd-pipeline/BRAIT-machine-learning-API:latest \ + --platform managed \ + --region asia-southeast2 \ + --allow-unauthenticated \ + --max-instances=1 \ No newline at end of file