Setting Up Google Cloud Run

  1. Download files from the Github repository to your computer

    1. Sign up for a Github account

    2. Establish authentication to Github API

      • Windows

        1. download VSCode

        2. download the Github Pull Requests Extension

        3. Click Accounts (bottom left) > sign in with Github

        4. All Git commands need to be done in VSCode's in-built terminal

      • MacOS

        1. Use VSCode, as above

        2. Alternatively, use a Personal Access Token

          1. Log into Github > Profile photo (top right) > Settings > Developer Settings (left menu, scroll down) > Personal access tokens > Tokens (classic) > Generate new token (top right) > Generate a new token (classic)

          2. Give name, expiration date, and scopes (for scopes, click "repo")

          3. Click Generate token

          4. When you run git clone (Step 2), it will ask for username and password. Use your Github username. For password, use the generated token.

          5. Cache token with git config --global credential.helper osxkeychain

            1. view cached credentials with echo url=https://github.com/git/git.git | git credential fill

    3. In your CLI, cd into where you want the “trading-view-automation” folder downloaded, then run git clone https://github.com/brianonchain/trading-view-automation.git

      1. Prompt will pop up > login with browser

      2. After the credentials are confirmed, the folder containing the files will downloaded

      3. Repo is only downloadable if you are invited as a collaborator to the private repo

  2. Upload files to Google Cloud Run

    1. Sign up an account on Google Cloud Platform

    2. Create a billing account

    3. Create a project

    4. Install the Google Cloud CLI, takes ~10 minutes (https://cloud.google.com/sdk/docs/installarrow-up-right)

    5. In your CLI:

      1. cd into the “trading-view-automation” folder you created in Step 1.3.4

      2. gcloud init

        1. Enter 1 for "Re-initialize this configuration [default] with new settings"

        2. Login with your Google username/password

        3. Select the project you created in Step 2.3

      3. gcloud run deploy --source .

        1. For the Service name, press Enter to use the default name ("trading-view-automation")

        2. enter y to enable APIs

        3. Choose region

        4. Enter y to allow unauthenticated invocations

        5. Wait ~5 minutes for files to build & upload

  3. Enter your environment variables

    1. Select your project in Google Cloud

    2. Click the menu (top left) > Cloud Run > click the trading-view-automation Service

    3. Click EDIT & DEPLOY NEW REVISION (top)

    4. Under Edit Container, click VARIABLES & SECRETS and enter environment variables (see Setting Up Env Vars)

    5. For better security, you can use Google Secrets Manager. For the best security, you can use Google Key Management Service (see Setting Up Google KMS)

  4. Copy the app URL and use it as the webhook URL in your Trading View alert or sendAlert.js

  5. If you need to update the Cloud Run code

    1. cd into "trading-view-automation folder", ensure you are on "main" branch, run git pull

    2. Follow Step 2.5.3

  6. Set up Google Sheets to see successful or failed trades (see Setting Up Google Sheets)

  7. Set up Telegram to see successful or failed trades (see Setting up Telegram)

Test Setup

Send a Trading View alert or mimic one using sendAlert.js. Use the provided Heroku HTTPS URL (see Step 1.4) as the webhook URL.

Last updated