From 57fcff959ba26e2495eaf442b01d93f080bfec9a Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Mon, 25 Aug 2025 17:36:40 -0300 Subject: [PATCH] chore: add ci --- .circleci/config.yml | 70 ++++++++++++++++++++++++++++++++++++++++++++ cloudbuild.yaml | 10 +++++++ 2 files changed, 80 insertions(+) create mode 100644 .circleci/config.yml create mode 100644 cloudbuild.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..52df26d6 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,70 @@ +version: 2.1 + +orbs: + node: circleci/node@5.2.0 + cloudrun: circleci/gcp-cloud-run@1.0.2 + gcp-cli: circleci/gcp-cli@3.3.1 + +# parameters: +# run_deploy_evolution_api: +# type: boolean +# default: false + +commands: + setup_npmrc: + description: "Create .npmrc file with GitHub token" + steps: + - run: + name: Create .npmrc file + command: | + touch .npmrc; + echo @voxityai:registry=https://npm.pkg.github.com/ >> .npmrc; + echo //npm.pkg.github.com/:_authToken=$GITHUB_ACCESS_TOKEN >> .npmrc; + + install_and_build: + description: "Install packages and build" + steps: + - node/install-packages: + pkg-manager: npm + - run: + name: Build application + command: npm run build + +jobs: + deploy_evolution_api: + docker: + - image: cimg/python:3.12.9-node + steps: + - checkout + # - setup_npmrc + - gcp-cli/setup + - setup_remote_docker + - install_and_build + - run: + name: Build and push Docker image + command: | + gcloud builds submit \ + --config=./cloudbuild.yaml \ + --substitutions=_CIRCLE_SHA1=${CIRCLE_SHA1},_GOOGLE_PROJECT_ID=${GOOGLE_PROJECT_ID},_GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} + - run: + name: Deploy to Cloud Run + command: | + gcloud run deploy evolution-api \ + --image gcr.io/$GOOGLE_PROJECT_ID/evolution-api-$CIRCLE_SHA1 \ + --region us-central1 \ + --platform managed \ + --allow-unauthenticated + +workflows: + deploy_evolution_api: + jobs: + - deploy_evolution_api: + context: evolution-api-dev + filters: + branches: + only: main + - deploy_evolution_api: + context: evolution-api-prod + filters: + branches: + only: production diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 00000000..e12e68cb --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,10 @@ +steps: + - name: 'gcr.io/cloud-builders/docker' + args: [ + 'build', + '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/evolution-api-${_CIRCLE_SHA1}', + '--build-arg', 'NPM_TOKEN=${_GITHUB_ACCESS_TOKEN}', + '.' + ] +images: + - 'gcr.io/${_GOOGLE_PROJECT_ID}/voxity-auth-${_CIRCLE_SHA1}'