|

|  How to Integrate Google Cloud AI with CircleCI

How to Integrate Google Cloud AI with CircleCI

January 24, 2025

Discover how to seamlessly integrate Google Cloud AI with CircleCI to automate workflows and enhance your DevOps pipeline with our comprehensive guide.

How to Connect Google Cloud AI to CircleCI: a Simple Guide

 

Set Up Google Cloud AI Environment

 

  • Create a Google Cloud account if you don't have one, and enable billing to access AI services.
  •  

  • Navigate to the Google Cloud Console and enable the APIs you require, such as the Vision AI or Natural Language API.
  •  

  • Generate service account credentials. Go to the IAM & Admin section, create a service account, and download the JSON key file.

 

Prepare Your Codebase

 

  • Ensure your application can access the Google Cloud services. Store the downloaded JSON key in a secure, accessible location.
  •  

  • Set environment variables in your application for accessing Google Cloud services. For example, if you're using a Node.js app, you might add environmental variables in your `.env` file as follows:
    GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/credentials.json
    
  •  

  • Add the Google Cloud client libraries to your application. For example, in a Node.js application, you might install the Vision library:
    npm install @google-cloud/vision
    

 

Configure CircleCI for Google Cloud

 

  • Log into CircleCI and set up your project. If your project is not listed, create a configuration for it.
  •  

  • Add environment variables to CircleCI for Google Cloud credentials. Navigate to your project settings in CircleCI, and under Environment Variables, add a variable with the key `GOOGLE_APPLICATION_CREDENTIALS` and the value that corresponds to the credentials JSON file path.
  •  

  • Securely store the Google Cloud credentials in CircleCI. You can use base64 encoding to avoid storing the raw JSON, for example:
    base64 /path/to/your/credentials.json
    

    Paste the encoded string into an environment variable and decode it in your configuration like so:

    version: 2.1
    
    jobs:
      build:
        docker:
          - image: circleci/node:14
        steps:
          - checkout
          - run: echo $GCLOUD_JSON | base64 --decode > ${GOOGLE_APPLICATION_CREDENTIALS}
    

 

Create a CircleCI Config File

 

  • Create a `.circleci/config.yml` file in your project root if it doesn’t exist.
  •  

  • Define the job that builds, tests, and deploys your application while integrating Google Cloud AI. Here's a basic example:
    version: 2.1
    
    jobs:
      build:
        docker:
          - image: circleci/node:14
        steps:
          - checkout
          - run: echo $GCLOUD_JSON | base64 --decode > ${GOOGLE_APPLICATION_CREDENTIALS}
          - run: npm install
          - run: npm test
          - run: npm run deploy
    

 

Test and Verify Integration

 

  • Commit the changes to your repository. CircleCI should automatically trigger a build using your configuration file.
  •  

  • Check the CircleCI dashboard to monitor the process and ensure all steps, including Google Cloud AI integration tasks, run successfully.
  •  

  • Address any errors by reviewing logs available on the CircleCI dashboard.

 

Omi Necklace

The #1 Open Source AI necklace: Experiment with how you capture and manage conversations.

Build and test with your own Omi.

How to Use Google Cloud AI with CircleCI: Usecases

 

Integrating Google Cloud AI with CircleCI for Automated Image Processing

 

  • Create a Google Cloud Platform (GCP) account and set up a project with Google Cloud AI services such as Vision AI to manage automated image processing tasks.
  •  

  • Design your application to include image processing capabilities using Google Cloud Vision AI. This might involve uploading images to Google Cloud Storage and utilizing Vision API to analyze them.
  •  

  • Develop a Continuous Integration/Continuous Deployment (CI/CD) workflow using CircleCI to automate software builds, tests, and deployment of your application.
  •  

  • Configure your CircleCI pipeline to trigger Google Cloud AI processing tasks whenever new images are uploaded to your application repository, ensuring that every image undergoes automated analysis.
  •  


version: 2.1

jobs:

  build:

    docker:

      - image: circleci/node:latest

    steps:

      - checkout

      - run:

          name: Install Dependencies

          command: npm install

      - run:

          name: Run Tests

          command: npm test

      - run:

          name: Deploy and Trigger GCP AI

          command: ./gcp-deploy-script.sh

 

  • Implement GCP IAM roles with appropriate permissions to allow CircleCI to securely access Google Cloud resources for the AI tasks.
  •  

  • Set up notifications or alerts in your CircleCI configuration to provide insights on the outcomes of the image processing, allowing your team to handle issues swiftly.
  •  

  • Monitor and scale your Google Cloud resources based on the image processing workload and adjust the CircleCI configuration to handle increased demand or optimize costs effectively.
  •  

 

 

Automated Sentiment Analysis with Google Cloud AI and CircleCI

 

  • Create a Google Cloud Platform (GCP) account and enable Natural Language API within your project. This will allow you to perform sentiment analysis on text data effectively.
  •  

  • Design your application to extract textual content, which could be user reviews, comments, or social media posts, and prepare it for sentiment analysis using the Natural Language API.
  •  

  • Develop a CI/CD pipeline using CircleCI to ensure that your application is continuously integrated and deployed with each code change, creating a reliable and consistent deployment environment.
  •  

  • Configure the CircleCI pipeline to automatically trigger a sentiment analysis task within Google Cloud AI whenever new text data is committed to the repository, thus maintaining real-time analysis.
  •  

```yaml
version: 2.1

jobs:

sentiment-analysis:

docker:

- image: circleci/node:latest

steps:

- checkout

- run:

      name: Install Dependencies

      command: npm install

- run:

      name: Execute Tests

      command: npm test

- run:

      name: Trigger Sentiment Analysis

      command: ./gcp-sentiment-script.sh # Script to invoke GCP Natural Language API

```

 

  • Set up proper IAM roles in GCP to grant CircleCI permissions required to access and utilize the Natural Language API, ensuring a secure interface between CircleCI and GCP.
  •  

  • Integrate notification settings in CircleCI to provide immediate feedback on the sentiment analysis results, enabling the decision-makers to react promptly to any significant findings.
  •  

  • Regularly review the performance and output of the Google Cloud resources and adjust the CircleCI tasks and workflows to optimize efficiency and cost-effectiveness as the text data scales.
  •  

 

Omi App

Fully Open-Source AI wearable app: build and use reminders, meeting summaries, task suggestions and more. All in one simple app.

Github →

OMI NECKLACE + OMI APP
First & only open-source AI wearable platform

a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded