Skip to content

hugolmn/dividend-chart-bot

Repository files navigation

Dividend Chart Bot

I have built a streamlit app with pretty nice looking charts. I wanted to create a Twitter bot that can generate and post them on-demand.

Architecture

Diagram

Run your own bot

Pre-requisites

Local development

git clone https://github.com/hugolmn/dividend-chart-bot.git
cd dividend-chart-bot

Building image using Google Cloud Build

  1. Install the gcloud CLI following these instructions
  2. Enable the Artifact Registry API.
  3. Create a registry Now, to create an image and store it into the registry, you can run the following commands from your code workspace:
gcloud builds submit --tag <YOUR_REGION>-docker.pkg.dev/<YOUR_PROJECT_ID>/<YOUR_REGISTRY>/<YOUR_IMAGE_NAME>:latest

Creating a Cloud Run Job

  1. Search "Cloud Run" > Select "Jobs" tab > "Create Job".
  2. For "Container image URL": select your registry in "Artifact Registry" > Select your image name > Select your image version
  3. If you always want to run on the lastest image version, replace the ending "@sha:******" by ":latest". in the "Container image URL".
  4. Select your job name, region, task capacity etc.
  5. In the "Variables & Secrets" tab, create the environment variables "api_key", "api_secret", "access_token", "access_token_secret", with the appropriate values from your Twitter developer account. You can also use secrets (free tier is limited to 6 secrets).
  6. Create your job.

Create a Cloud Scheduler

  1. Enable the Cloud Scheduler API if needed.
  2. Create a job following these instructions.

Congratulations! Your bot is now all set!